2012-11-24 36 views
6

由于arguments.callee将被弃用,我将在下面的表达式用什么来代替arguments.callee`的:arguments.callee的替代

var self = this; 

this.async(function(){ 
    if(test()){ 
    then(); 
    }else{ 
    self.async(arguments.callee); 
    } 
}); 
+0

的可能重复[arguments.callee的已经过时? - 应该怎样来代替(http://stackoverflow.com/questions/8361642/arguments-callee-is-deprecated-what-should-be-用来代替) – DavidRR

回答

4

这应该工作。但我不确定它是否适用于所有浏览器。

var self = this; 

this.async(function someMethod(){ 
    if(test()){ 
    then(); 
    }else{ 
    self.async(someMethod); 
    } 
}); 
+2

着名的[Kangax文章](http://kangax.github.com/nfe/)详细介绍了错误/怪癖,但通常它仍然有效。 –