Booleans

There are only two values that belong to the Boolean data type: the values true and false, used without quotes:

> var b = true; 
> typeof b;
"boolean"
> var b = false; 
> typeof b;
"boolean"

If you quote true or false, they become strings:

> var b = "true"; 
> typeof b;
"string"

Get Object-Oriented JavaScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.