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
  • 71,580
  • 16
  • 111
  • 150
dagda1
  • 26,856
  • 59
  • 237
  • 450
  • 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,921
  • 2
  • 19
  • 26
  • 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