There is a function:

function some_f() { this.first = function () { //code } this.second = function () { //code } } 

It is necessary that at the first start only the method first returned, and at any subsequent only second . For example:

 some_f().second()//ошибка //именно в такой последовательности: some_f().first();//верно some_f().first();//ошибка some_f().second();//верно 

    1 answer 1

     function some_f() { if (some_f.counter == undefined) some_f.counter = 0; some_f.counter++; this.first = function () { alert('first'); } this.second = function () { alert('second'); } if (some_f.counter > 1) { return this.second() }else { return this.first(); } }