JavaScript: true/false (boolean)

By Xah Lee. Date: . Last updated: .

true and false are builtin Primitive Values . And they are the only possible values of boolean type [see JavaScript: Value Types].

console.log((typeof true) === "boolean");
console.log((typeof false) === "boolean");

[see JavaScript: typeof Operator]

Force Convert Any Value to Boolean

When a value is evaluated in boolean context, such as in a Branch Control: if then else, switch , the function Boolean is called on the value, to force the value into true or false.

What Values Are False

Anything else is true.

[see JavaScript: Boolean Constructor]

JavaScript Boolean

JavaScript Operators

BUY
Ξ£JS
JavaScript in Depth