Truthiness
Javascript (and other languages) have something called Truthiness. Ok, it's actually called Truthy
or Falsy
. It is the idea that we can infer something is true, similar to assuming.
Falsy
If something does not exist (like NaN
) or has a value equating to zero, it is considered false
. For example, an empty string of ""
would be considered false. It has no value.
Truthy
If the data has value (other than specifically NaN
, zero, or false
) it is considered true
, because it has value. For example, 1 == '1'
will result in true
because they are equal in value (Javascript converts on-the-fly). However, 1 === '1'
will return false
because they are not exactly equal (one is a numeric value, the other a string).
NaN
stands for Not a Number. Think of it like "undefined" or "does not exist".
Note: division by zero gives an answer of infinity.
Last updated