The following shows that "0" is false in Javascript:
"0"
>>> "0" == false true >>> false == "0" true
So why does the following print "ha"?
"ha"
>>> if ("0") console.log("ha") ha
Tables displaying the issue:
and ==
Moral of the story use ===
table generation credit: https://github.com/dorey/JavaScript-Equality-Table
2.1m questions
2.1m answers
60 comments
57.0k users