J

JavaScript Handbook

Clean • Professional

JavaScript Comparison Operators

1 minute

JavaScript Comparison Operators

Comparison operators are used to compare two values. They return a Boolean: true or false.

1. Equal (==)

Checks if two values are equal (loose comparison).

console.log(5 == "5"); // true

2. Strict Equal (===)

Checks if two values are equal and of the same type.

console.log(5 === "5"); // false

3. Not Equal (!=)

Checks if two values are not equal (loose comparison).

console.log(5 != 3); // true

4. Strict Not Equal (!==)

Checks if two values are not equal or not of the same type.

console.log(5 !== "5"); // true

5. Greater Than (>)

Checks if the left value is greater than the right.

console.log(7 > 3); // true

6. Less Than (<)

Checks if the left value is less than the right.

console.log(7 < 3); // false

7. Greater Than or Equal (>=)

Checks if the left value is greater than or equal to the right.

console.log(5 >= 5); // true

8. Less Than or Equal (<=)

Checks if the left value is less than or equal to the right.

console.log(3 <= 5); // true

Summary Table

OperatorMeaningExample
==Equal5 == "5"
===Strict Equal5 === "5"
!=Not Equal5 != 3
!==Strict Not Equal5 !== "5"
>Greater Than7 > 3
<Less Than7 < 3
>=Greater or Equal5 >= 5
<=Less or Equal3 <= 5


Article 0 of 0