不想为扩展之前的问题开一个新问题:
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;
}
}
}
这个返回值是iteration = 5但结果未定义?这怎么可能?我明确地返回了sWord。它应该返回“hahalollollollollol”,只是为了双重检查,如果我在返回sWord之前警报(alert)sWord,它正确地显示出来。