Hacker News new | past | comments | ask | show | jobs | submit login

If you try to combine object methods that use 'this' with functional programming-style code, you're in for a bad surprise



Yea, 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.


And 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.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: