News for hackers. Stuff that matters.
Re:“This” in JavaScript by marrs on Monday December 08, 2014 @09:48AM (#8716646)
I'd say I use `this` outside of lexical context at least as much as I do within, and I rely on this's behaviour a lot when developing a DSL.

It enables some rather elegant patterns, actually.

Re:“This” in JavaScript by DonHopkins on Monday December 08, 2014 @01:00PM (#8717893)
Patterns which could have been just as easily implemented using another more explicit technique for dynamic binding (like simply passing the dynamic parameter to the function as a normal argument) without fucking up the entire language design with invisible implicit magic, and dooming millions of programmers to repeatedly make difficult to detect, subtle mistakes, bugs and security holes.

Please give me one example of using "this" outside of lexical context, that is impossible or tangibly inconvenient to do by some other technique that JavaScript already supports.

Re:“This” in JavaScript by marrs on Tuesday December 09, 2014 @08:49AM (#8722641)
Well, you could pass around the object but then you'd have to come up with a new object-literal syntax because `this` won't exist any more, unless you're planning on keeping it around but keeping it lexically scoped, in which case you have to stop using object literals as traits and prototypes.

At that point you might as well just redesign the language from scratch, which maybe you'd appreciate.

Guess I'm just not feeling the hate on this one.