angular / prophecy

Deferred/Promise for AngularJS 2.0
Other
36 stars 6 forks source link

ES6 Arrow functions 'this' is from lexical scope of enclosing block (no need to use Function#bind()) #4

Closed caitp closed 10 years ago

caitp commented 10 years ago

https://github.com/angular/deferred/blob/master/src/Deferred.js#L3-L6 is using bind when it's not really necessary in ES6. Arrow functions should perform better once supported natively, and Traceur's implementation should already perform better due to not creating a new function.

Traceur's version of this also improves performance and avoids creating a new function, by just creating an alias variable for this and replacing this with the alias within the call.

btford commented 10 years ago

:+1: