This is important, think about it:
thisis a problematic keyword in JS, in general with the fact that it can be changed, can cause a lot of headaches for Object Oriented
- Missing immutability is painful because most library will pass you simple objects and you always have to convert to/from ImmutableJS or similar libraries (if you want immutability ensured) or you need a set of libraries to deal with objects without touching them (any recommendation?)
- Every developer comes with its own ideas, so you must deal with multi-paradigm in your code as soon as you use any external libraries
These are just 3 points, but for me are the weakest sides of the multi-paradigm approach. I really hope the language will be updated to provide solutions.
- You don’t like
thischanging, or you are using
=>to bind your functions
- You decide to simply clone your object to use it for a different purpose
- The object is cloned with all its functions, except that those are bound to the old instance, with nasty consequences
Now it’s obviously something you can work around with a proper Clone service, but again, why do I have to face all this pain when I can just use functions on objects?
It’s not perfect, but when you work with immutable data, ES6 modules, raw objects (like if they are hashmaps), it starts to feel pleasant.