|
|
|
|
|
by tracker1
2028 days ago
|
|
I don't so much think of them as flaws... the first use case was form validation, and most of the fuzzy type coercion makes a ton of sense through that lens, where ''. 0, etc. coercion to falsy is easy for dealing with user input. It's also why it's one of my favorite options for ETL workloads. It's just a matter of understanding the langauge. That said, it's been my favorite language since well before the "good parts" book. |
|
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.