3 ms·
There is both null and undefined in JavaScript. Additionally, an empty array coerces to true because it's an object and objects are always truthy. Personally I
by samhh 7y ago
There is both null and undefined in JavaScript. Additionally, an empty array coerces to true because it's an object and objects are always truthy.
Personally I'd prefer that not even null/undefined coerced to false, or could otherwise be used in a boolean comparison, as for me they still signify different meanings and even in type-safe languages can lead to subtle bugs. I really dislike coercion having principally worked with JavaScript/TypeScript.