8

As arguments.callee is going to be deprecated, what would I use of instead of arguments.callee` in the following expression:

var self = this;

this.async(function(){
  if(test()){
    then();
  }else{
    self.async(arguments.callee);
  }
});
bfavaretto
  • 70,503
  • 15
  • 107
  • 148
dagda1
  • 23,659
  • 54
  • 216
  • 399
  • possible duplicate of [Arguments.callee is deprecated - what should be used instead?](http://stackoverflow.com/questions/8361642/arguments-callee-is-deprecated-what-should-be-used-instead) – DavidRR Jun 18 '15 at 19:25

1 Answers1

5

This should work. But i'm not sure if it works in all browsers.

var self = this;

this.async(function someMethod(){
  if(test()){
    then();
  }else{
    self.async(someMethod);
  }
});
Florian Salihovic
  • 3,881
  • 2
  • 17
  • 24
  • 2
    The famous [Kangax article](http://kangax.github.com/nfe/) details the bugs/quirks, but generally it'll still work. – I Hate Lazy Nov 24 '12 at 15:00