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].

(typeof true) === "boolean";

(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

BUY Ξ£JS JavaScript in Depth