JavaScript: falsy

JavaScript is pretty lenient when it comes to boolean evaluation.

Everything is a booly which can be falsy or truthy.  You heard me, I said booly.

There are eight values in JavaScript that are falsy.

typeof argument   argument       Result
“undefined”       undefined    → false

“boolean”         false         → false
                  true         → true

“number”          0.0          → false
                  -0.0         → false
                  NaN          → false
                  otherwise    → true

“string”          “”           → false
                  otherwise    → true

“object”          null         → false
                  document.all → false
                  otherwise    → true

“function”        any          → true


Posted in Uncategorized | Leave a comment