...

/

Relational and Boolean Operators

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:

  1. If both operands are numbers, a numeric comparison is carried out.

  2. If both operands are strings, the character codes of each corresponding character in the string are compared.

  3. If one operand is a number, the other operand is converted to a number, and a numeric comparison is performed.

  4. If an operand is an object, valueOf() is called, and its result is used to perform the comparison according to the previous rules. If valueOf() ...

Access this course and 1400+ top-rated courses and projects.