Boolean type values only have two results: true or false.
The words true and false are actual keyword values here.
Comparing Boolean values with the “less than” or “greater than” operator
The > operator means “greater than” and the < operator means “less than.”
These are binary operators and thus require two values. One on the left of it and one on the right of it.
This makes sense because the concept of comparing involves at least two values.
When we use either of these two operators, the result can only be a single true or false.
Let’s use the > and < operators in an example.
Example 1: How does the “greater than” operator work?
What’s the output of this expression?
console.log(10 > 2);
The output is:
true
This is because the > operator is asking us, whether or not the expression is true or false.
In the code, it’s literally saying, “is 10 greater than 2?”
The answer’s yes which is true.
Example 2: How does the “less than” operator work?
Same example as above but using the < operator.
console.log(10 < 2);
Is this true or false?
The answer is:
false
So, is “10 less than 2” in this expression?
No, of course not.
It’s false.