JavaScript Is Weird
<i>0.2 + 0.1 === 0.3</i><p>That's not really a JS problem, that's a floating point problem. Plenty of languages will have the same issue.<p><i>+!![]</i><p><i>"" - - ""</i><p><i>(null - 0) + "0"</i><p>Calling these things weird is fair enough but I can't help thinking this is code you'd never actually write outside of the context of a "Look how weird JS is!" post. It's like picking examples from the Annual Obfuscated C Contest to show how hard it is to understand C. Yes, some languages enable you to write weird garbage code that's hard to reason about, and ideally they wouldn't because enforcing sane code would be great, but <i>come on</i>. Most of these things aren't a big problem that we suffer every day. Just be <i>moderately</i> careful about casting things from one data type to another and <i>all</i> these problems go away.