Thursday, February 2, 2017

falsey six

Yikes! There are not five falsey values as I suggest here and here but instead at least six as the Boolean value for false is obviously falsey as it's literally false. This moreover makes a distinction between negative zero and zero and between an empty string defined with single quotes and an empty string defined with double quotes and all four things are falsey. The same thread suggests there is an obscure thing called document.all which is of old IE that is also falsey, so there could be as many as nine falsey shapes.

  1. undefined
  2. null
  3. false
  4. NaN
  5. 0
  6. ""
  7. ''
  8. -0
  9. document.all

No comments:

Post a Comment