JS: Boolean. true false

By Xah Lee. Date: . Last updated: .

Literal true and false

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

console.assert((typeof true) === "boolean");

console.assert((typeof false) === "boolean");

[see JS: typeof (operator)]

Force Convert Any Value to Boolean

When a value is evaluated in boolean context, such as in a if then else , 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 JS: Boolean Constructor]

JavaScript. Boolean

JavaScript. Operators