Relational and Boolean Operators
In this lesson, we'll cover relational and Boolean operators. Let's begin!
Relational operators
Besides the equality operators, JavaScript defines four relational operators, similar to other programming languages.
These are less than (<
), greater than (>
), less than or equal to (<=
), and greater than or equal to (>=
). Each returns a Boolean value representing the result of the comparison.
Operand rules
These operands work according to these rules:
-
If both operands are numbers, a numeric comparison is carried out.
-
If both operands are strings, the character codes of each corresponding character in the string are compared.
-
If one operand is a number, the other operand is converted to a number, and a numeric comparison is performed.
-
If an operand is an object,
valueOf()
is called, and its result is used to perform the comparison according to the previous rules. IfvalueOf()
...