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.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
var a = new Boolean(false);var b = false;if (a) console.log("a"); // loggedif (b) console.log("b"); // not loggedif (!0) console.log("!0"); // loggedif ("0") console.log("0"); // loggedif ([]) console.log("[]"); // loggedif ({}) console.log("{}"); // loggedif (document.all) console.log("document.all"); // not logged
</script></body><html>
This roughly converts a string to a Boolean primitive. |
String(s).toLowerCase() == 'true' |