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
1.4m articles
1.4m replys
5 comments
57.0k users