3 ms·
One 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
by anyfoo 4y ago
One 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...