In JavaScript, why is “0” equal to false, but when tested by ‘if’ it is not false by itself?

Tables displaying the issue:

truthy if statement

and ==
truthy comparisons of all object types in javascript

Moral of the story use ===
strict equality displaying sanity

table generation credit: https://github.com/dorey/JavaScript-Equality-Table

Leave a Comment