JavaScript syntax: Difference between revisions

Content deleted Content added
Line 374:
===Boolean===
 
[[JavaScript]] provides a [[Boolean data type]] with {{mono|true}} and {{mono|false}} literals. The {{mono|[[typeof]]}} operator returns the string {{mono|"boolean"}} for these [[primitive types]]. When used in a logical context, {{mono|0}}, {{mono|-0}}, {{mono|null}}, {{mono|NaN}}, {{mono|undefined}}, and the empty string ({{mono|""}}) evaluate as {{mono|false}} due to automatic [[type coercionconversion]]. All other values (the [[complement (set theory)|complement]] of the previous list) evaluate as {{mono|true}}, including the strings {{mono|"0"}}, {{mono|"false"}} and any object.
 
=== Type conversion ===