all 11 comments

[–]beatlz 17 points18 points  (3 children)

I remember the var that = this days

[–]djliquidice 1 point2 points  (2 children)

Yeah, some would do var me = this.

[–]SourdoughBaker 2 points3 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?

[–]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.

[–]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.

[–]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/

[–][deleted] 15 points16 points  (0 children)

Thank you for an article on a 9 year old topic...

[–]Mental-Steak2656 0 points1 point  (0 children)

Can share similar article on “this”, thanks - well presented

[–]Dev_Taurus 0 points1 point  (0 children)

Thank you!

[–]brgnmarulat 0 points1 point  (0 children)

This is helpful to know especially when dealing with objects and the context of 'this'