Defend this statement. I don’t agree at all. Closures exist in many languages and behave more or less the same way in all the languages that support them. The behavior of ‘this’ in JS is, AFAIK, completely unique and can seem like magic when coming from any other language.
The fact that calling ‘myArray.map’ behaves differently from ‘mapMyArray’ is useful in some situations (not this one, it just breaks) and completely core to the language, but it is mostly just weird and dumb. This is the entire reason arrow functions were added.
I’ve used dynamic this binding plenty, ‘Array.prototype.slice.call(myNodeList)’ is a fairly common use case, but if I could, I would have it removed for all the times it causes confusion and makes the language harder to learn.
6
u/j4afar May 28 '19
Bind and the this keyword