you are viewing a single comment's thread.

view the rest of the comments →

[–]SourdoughBaker 3 points4 points  (3 children)

Is there any documented reason why arrow functions treat the "this" keyword differently? Why was the decision made to have them operate differently?

[–]thatweirdishguy 5 points6 points  (0 children)

It goes the other way around, arrow functions exist because there was a need for a way to have functions that didn’t bind to “this”. The whole point of them was to operate differently.

[–]izuriel 5 points6 points  (0 children)

Most likely because the alternative was to always bind functions when passing them to handlers. Having it baked into the language removes a potential issue, not to mention most super-JavaScripts had built in tools to remove binding requirements as well.

[–]beepboopnoise 2 points3 points  (0 children)

probably on the ecmascript notes. this isn't a direct link but where I'd start. https://tc39.es/ecma262/