Hate to open a new question to expand the previous one:
function ctest() { this.iteration = 0; this.func1 = function() { var result = func2.call(this, "haha"); alert(this.iteration + ":" + result); } var func2 = function(sWord) { this.iteration++; sWord = sWord + "lol"; if ( this.iteration < 5 ) { func2.call(this, sWord); } else { return sWord; } } }
returns iteration = 5, but is the result UNDEFINED? how is this possible? I explicitly return sWord. It should have returned "hahalollollollollol" and just for doublecheck, if I warn (sWord) immediately before returning sWord, it displays it correctly.
source share