Learn Create Your Own Split Screen

Next Page

Examples
Numbers Strings Booleans
123 "hello" true
0 "I like bananas" false
-73.2 "I'm hungry"
0.017 'watermelon'
90000 ":)"

Booleans can only be true or false -- nothing else.

They may seem a little odd, but they're particularly useful in if statements and while loops.

In fact, we frequently end up with a boolean from comparing a couple of non-booleans. Consider the following code fragement:

if (73 < 100) {alert("less!")}
The 73 and 100 are obviously numbers, but after we compare them using the less-than operator, what you end up with is a true/false result. It can't be anything else.