Tuesday, March 14, 2017

Use bind to pass the scope of this down to a JavaScript function without the self=this hack!

var x = function(whatever) {
   return whatever + this.something;
}.bind(this);

No comments:

Post a Comment