MENU
Boolean
A Boolean value is either 'true' or 'false'. A Boolean variable can be initialized with a primitive Boolean value or a Boolean object.
The following all evaluate to 'false': false, 0,-0, null, undefined, NaN, “”, document.all
All other values evaluate to 'true'.
Do not confuse the primitive Boolean values 'true' and 'false' with a Boolean object.
var a = new Boolean(false);
var b = false;
if (a) console.log("a");
if (b) console.log("b");
if (!0) console.log("!0");
if ("0") console.log("0");
if ([]) console.log("[]");
if ({}) console.log("{}");
if (document.all) console.log("document.all");a
!0
0
[]
{}
| This roughly converts a string to a Boolean primitive. |
| String(s).toLowerCase() == 'true' |