JavaScript types: boolean types
Boolean values evaluate to the reserved words true
and false
. They have a toString()
method that returns those reserved words as strings: (1 === 1).toString()
returns 'true'
.
Falsy values are undefined
, null
, 0, -0, NaN
, and the empty string. Everything else is truthy.
&&
and ||
short-circuit.
Sources
Flanagan, David. Javascript: The Definitive Guide. 6th ed, O’Reilly, 2011.