3 ms·
It’s been more than a decade of this drivel, that largely is not weird or bizarre if you actually think about what is being shown. The only legitimate complaint
by olliej 4y ago
It’s been more than a decade of this drivel, that largely is not weird or bizarre if you actually think about what is being shown. The only legitimate complaints come from the type coercion rules, and even those are completely consistent albeit suffering from the era of “scripting languages should do conversions implicitly”.
Things like
{} + {}
Behave weirdly, only if you don’t ask what happens in every other brace based language when given that syntax: the first {} is parsed as a block statement in C, C++, Java, C#, giving you a +{} expression.
Similarly conflating repl output with the value of expressions as though the language is doing something odd.
Or the absurd belief that typeof NaN should be something other than number. While I do love the idea of statically typed languages being forced to crash on NaN results at runtime, that being because the value type is suddenly wrong is stupid.
- anyfoo 4y agoOne can fully understand the type coercion rules and the effects that result from them, and still acknowledge that said type coercion rules are not optimal, at least because they lead to very non-optimal outcomes. I for one am tired of people claiming that this is not "weird or bizarre", because not only is it obvious that several parts of JavaScript including the type coercion rules are (at best) strange, it's also absolutely not surprising from its history: The person who originally invented JavaScript wanted to implement Scheme, but management wanted to go for "something similar to Java". JavaScript was prototyped in ten days[1], and I doubt anyone back then really anticipated the role it would later come to have. There is an entire standards body that aims to hammer JavaScript into something that makes more sense, because, well, we're stuck with. (Or rather, you are stuck with it, I don't do web development.) https://web.archive.org/web/20200227184037/https://speakingjs.com/es5/ch04.html https://web.archive.org/web/20200227184037/https://speakingj...