3 ms·
I disagree that is not inherent to Javascript. The way "this" is promiscuous among functions allows methods to be "just" function properties and is integral to
by ufo 15y ago
I disagree that is not inherent to Javascript. The way "this" is promiscuous among functions allows methods to be "just" function properties and is integral to prototypical inheritance.
The alternative closure-based OO style also works fine most of the time but it has some limitations, such as not being able to define protected properties that can be accessed in a subclass.
Of course, "this" breaking inside inner helper functions and event handlers (and having to use "var that" or Function.prototype.bind) is annoying as hell but is more of a syntax issue (fixed by things like CoffeeScript and the proposed #() lambda syntax for ES6)