by masswerk · 12y ago · 0 comments
Personally, I would suggest the introduction of another variable, providing a "sticky this", which would stay bound to the this-object of the scope, the function was declared in. But what would be the reserved word to be used for it? (This would have to be restricted to arrow-functions, since there would be inconsistencies when assigning a method to an other object.)
Instead of -> {...} replacing function() {...}
We get => {...} replacing (function() {...}).bind(this)
Why should the less common case get the more convenient syntax? Especially considering when we already have Function.prototype.bind to do this. How could they possibly agree on this but not the thin arrow?
Well you cant use it unbound. I dont want to declare functions bound to a scope I want a quick way to declare functions.
So this is a) a personal view on this (as pointed out clearly) and b) not raised deliberately.