5 ms·
If you try to combine object methods that use 'this' with functional programming-style code, you're in for a bad surprise
by rtpg 12y ago
If you try to combine object methods that use 'this' with functional programming-style code, you're in for a bad surprise
- woah 12y agoYea, when people try to rebuild all the fanciful embellishments of classic OOP GUI programming in JS, they're going to have a hard time. Unfortunately I've had to maintain this kind of code in the past. Don't use 'this'. I'm afraid that the addition of the 'class' keyword in es6 will make this tendency worse in some programmers. Along with block scoping, it's a feature lobbied for by people who don't actually code much JS.
- orangecat 12y agoAnd that's JavaScript's fundamental problem: it's full of attractive nuisances that have the nasty property of silently doing the wrong thing. 'this', 0=='0'==false==[]!=[], global variables by default, objects that are almost-but-not-quite maps, for-in-oops-forgot-hasOwnProperty, etc, etc.