PART I: AT THE GATES OF ENLIGHTENMENT
1.9 Comparison operators and booleans
===, !==, <, >, <=, >= true, false
In math we use the equals sign to determine equality.
x = 12;
In the example above, 12 is given to x. This is an assignment, not a question to inspect equality.
To inspect equality, we use the triple = operator ===
x === 12;
The expression above is not an assignment, it is a question and the question is: “are the values in x and in 12 the same?” in other words, does the variable x contain the numeric value 12?
What is a Boolean?
A Boolean is a binary evaluation result that has one of two possible value outcomes:
x === 12;
Else, it will reply false, like in the following example:
x === 14;
ReferenceError: x is not defined
Please remember, these symbols compare the left operand, to the right operand.
Less than: <
Greater than: >
Less or equals than: <=
Greater or equals than >=
Not the same as: !==
12 < 10; The Boolean answer is false
12 > 10; The Boolean answer is true
12 === 12; The Boolean answer is true
12 === "12"; The Boolean answer is false*
12 !== 13; The Boolean answer is true
12 !== 12; The Boolean answer is false
12 <= 12; The Boolean answer is true
12 = 12; The Boolean answer is true