4 ms·
Falsey 0 in JavaScript is a big source of problems and is often linted against (forcing explicit checks, which then make code a bit uglier, but at least you won
by brundolf 4y ago
Falsey 0 in JavaScript is a big source of problems and is often linted against (forcing explicit checks, which then make code a bit uglier, but at least you won't get bitten by the case where 0 gets treated like null instead of a number)
Count yourself lucky
Edit: Thinking about it, this is probably a frame-shift from static to dynamic languages, because in the latter any value can be nil/null at any time. Whereas in C, C++, and even Java etc, unboxed numbers are always numbers. So coming from those you may not be used to thinking about the case where you have a nullable number and mean to check for null and accidentally also check for 0. But in dynamic languages like Clojure, it's a common situation to have a nullable number.