arguments.callee的替代方案

8

由于arguments.callee即将被弃用,那么在以下表达式中,我应该使用什么替代arguments.callee

var self = this;

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

1个回答

5

这应该可以工作。但我不确定它是否在所有浏览器中都有效。

var self = this;

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

2
著名的Kangax文章详细介绍了一些错误/怪异情况,但通常它仍然可用。 - I Hate Lazy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接