Boolean
Something that is only true or false.
A boolean has one of two possible values: true
or false
. The boolean (logical) operators (and, or, not) take boolean inputs and make another boolean value. Comparing on other types (numbers, strings) with logical operators create boolean values.
These blocks represent the true
and false
boolean values, which can be plugged in anywhere a boolean value is expected:
let on = true;
let off = false;
off = false;
You can set and compare other boolean values:
let on = true;
let off = false;
let switcher = on;
let light = off;
if (switcher) {
light = on;
} else {
light = off;
}
Compare other types:
let cool = 50;
let temp = 65;
let warming = temp > cool;
if (warming) {
let message = "It's warming up."
}