3 ms·
Fair question, here's a few: - object methods cannot be passed as arguments to a function or another method like regular functions can because they lose their
by lliamander 4y ago
Fair question, here's a few:
- object methods cannot be passed as arguments to a function or another method like regular functions can because they lose their 'this' pointer.
- array.sort() is broken. It does the sort in-place and converts the elements to strings before sorting.
- const doesn't support separate declaration and assignment. This makes it harder to conditionally decide what to assign to a variable while still making it const.
- number types.
- the fact that you have to use '===' for the normal understanding of equality
- Date handling could be better
- NPM has a number of problems, including default behavior of updating your dependency versions.
- shadowgovt 4y agoThat's a good list, and I was right; I've been at this so long I've forgotten that most of those are 'WAT' to the average user. Regarding `object methods cannot be passed as arguments to a function or another method like regular functions can because they lose their 'this' pointer.`: yeah, the fact that JS objects are actually kinda weird li'l things is frustrating. There are nowadays two ways to handle that: - referencing the object in a closure binds the object instance. `(x) => foo.bar(x)` will do the right thing - there is an explicit bind operator, so you can do `myCallbackTaker(instance.myFunction.bind(instance))` ... but I agree that in a better language, you'd be expected to do neither of those things.
- lliamander 4y agoThanks for the tip about binding the object instance. Just to share an experience on the other end, I worked with Erlang several years back. While it was a harder language to learn, every new thing I learned about the language gave me the impression that the language designers did the right thing. Don't get me wrong, I'm having fun with my current Typescript/NodeJS stack at work, but if I was building my own stuff it would absolutely be on the Erlang VM.