| I use JS every day; I would say I like it. I would even say that in 2020, if you know what you're doing, it's a pretty good language on the whole. But I don't think it's controversial to say that the following were objectively bad decisions (in hindsight, of course, but still): - Automatic casting behavior between the core types (you're the only person I've ever heard suggest that this might be a good thing) - Automatic semicolon insertion - A core Date object that lacks basic control over time-zones and reasoning about time-zones - Assigning to an undeclared variable silently creates a global - Allowing duplicate function parameter names where later ones just hide the earlier ones - Distinction between undefined and null (this one might have a few defenders) Some of these are now prevented by "strict mode". Others have been patched-over, for example by the addition of === which prevents casting behavior for comparisons at least. Others can be bridged by libraries (Moment.js) or by best-practices (use foo == null to smooth over the null/undefined distinction, never use a value's implicit falsiness in a conditional, etc). But the point is that JavaScript has this giant asterisk that will never go away, of things you need to do/avoid/utilize in order to get the most basic behaviors right. |
I didn't like TS at first, but using the most recent version has been relatively pleasant and working with less experienced devs has been almost required in order to do further refactors. I killed a month trying to do a complex refactor ad-hoc, in circling around, I was able to convert the entire project to TS in a couple days, introduce typing for core state and a few other areas which allowed me to do the rest of the refactor in a couple days. That sold me on TS, as long as I don't HAVE to type everything, or jump through the hoops as I did on my first experience with TS, which was combined with Angular projects.
The casting behavior is definitely a foot-gun, but it's powerful as I mention for validation and ETL type workflows. The "falsy" values list is literally my guide marker in interviews for JS devs. It's usually a pretty good benchmark for how well a developer understands the language itself..
Totally agreed on the Date object. Absolutely horrible, and moment, while useful was huge and most other hacks aren't all that great either. The Date object really should be extended as probably the next major bump in usability in the system. Even if it was just extended enough for parity for what C#/.Net offers for their DateTime/DateTimeOffset then other libraries could flush it out and be much smaller.
One useful thing to know, is that assigning an object property to undefined will skip that property as part of json serialization and is faster than delete on the property I'll often do something like return JSON.stringify(Object.assign({}, original, {propToHide: undefined}) in node APIs. This is about the only useful bit from undefined I can think of off hand.
Global variable assignment by default is definitely a flaw.