Open In App

JavaScript Comparison Operators

Last Updated : 21 Nov, 2024
Summarize
Comments
Improve
Suggest changes
Share
1 Like
Like
Report

JavaScript comparison operators are essential tools for checking conditions and making decisions in your code.

1. Equality Operator (==)

The Equality operator is used to compare the equality of two operands.


Output
true
true
true

false
true
false

2. Inequality Operator (!=)

The Inequality Operator is used to compare the inequality of two operands.


Output
true
false
false

false
true
true

3. Strict equality Operator (===)

The Strict equality Operator is used to compare the equality of two operands with type.


Output
false
true
false

false
false
false

4. Strict inequality Operator (!==)

The Strict inequality Operator is used to compare the inequality of two operands with type.


Output
true
false
true

true
true
true

5. Greater than Operator (>)

The Greater than Operator is used to check whether the left-side value is greater than the right-side value.


Output
true
true
false
true

6. Greater than or equal Operator (>=)

The Greater than or equal Operator is used to check whether the left side operand is greater than or equal to the right side operand.


Output
true
true
true
false

7. Less than Operator (<)

The Less than Operator is used to check whether the left-side value is less than the right-side value.


Output
true
false
false
true

8. Less than or equal Operator (<=)

The Less than or equal Operator is used to check whether the left side operand value is less than or equal to the right side operand value.


Output
true
false
false
true

Comparison Operators List

There are many comparison operators as shown in the table with the description.

OPERATOR NAME

USAGE

OPERATION

Equality Operatora == bCompares the equality of two operators
Inequality Operatora != bCompares inequality of two operators
Strict Equality Operatora === bCompares both the value and type of the operand
Strict Inequality Operatora !== bCompares inequality with type
Greater than Operatora > bChecks if the left operator is greater than the right operator
Greater than or equal Operator a >= bChecks if the left operator is greater than or equal to the right operator
Less than Operatora < bChecks if the left operator is smaller than the right operator
Less than or equal Operatora <= bChecks if the left operator is smaller than or equal to the right operator

Recommended Link

JavaScript Operators Complete Reference.
JavaScript Cheat Sheet-A Basic guide to JavaScript.


Next Article

Similar Reads