2 ms·
If you look at this jsbin, you might get a better feel for what's being discussed: https://jsbin.com/cejuyijahu/1/edit?js,console https://jsbin.com/cejuyijahu/
by Lazare 11y ago
If you look at this jsbin, you might get a better feel for what's being discussed: https://jsbin.com/cejuyijahu/1/edit?js,console https://jsbin.com/cejuyijahu/1/edit?js,console
If you use an OOP style (with classes and inheritance), then you end up needing to use the 'this' keyword. If you use a functional style, you don't.
Is the functional style better? Does it let you write more reusable code, and avoid tightly coupling it to date? Eh...maybe. If you like that style, you'll probably be more productive that way (and be intrigued by Cycle.js). If you don't like that style, you won't be.
Also:
> the statement above implies the existence of 'this' is a failure of JavaScript's design
It's certainly been a pain point, and there's a lot of confusion and debate over classes, prototypes, constructors, the this keyword, figuring out what 'this` even refers to at any given point, the 'new' keyword, etc. I'm not sure I'd agree that the existence of the 'this' keyword is a mistake (and I doubt the people behind Cycle.js would either), but I don't think it's controversial to note that you can avoid a lot of confusion and sidestep the whole thing, if you are of a mind, by just using plain functions returning objects as needed.