# JavaScript Comparison Operators

• Last Updated : 24 Mar, 2022

In this article, we will know about various comparison operators & their implementation in Javascript. The Comparison operators are mainly used to perform the logical operations that determine the equality or difference between the values.

Operators are used to performing specific mathematical and logical computations on operands. Like C, C++, Java, Python, and various other languages, JavaScript also supports Comparison operations. Comparison operators are used in logical expressions to determine their equality or differences in variables or values.

Example: Below is the example of the comparison operators.

## Javascript

 ``

Output:

```true
true```

There are various comparison operators supported by JavaScript:

• Equality Operators
• Relational Operators

We will discuss both the operators sequentially through the examples.

Equality Operators:

Equality (==):  This operator is used to compare the equality of two operands. If equal then the condition is true otherwise false.

Syntax:

`x == y`

Example 1: Below example illustrate the (==) operator in JavaScript.

## Javascript

 ``

Output:

```> true
> true
> true
> true
> false```

Example 2: This example describes the equality operator to compare the 2 object’s values.

## Javascript

 ``

Output:

```> true
> false
> true
> false
> true```

Inequality(!=): This operator is used to compare the inequality of two operands. If equal then the condition is false otherwise true.

Syntax:

`x != y`

Example 1: Below examples illustrate the (!=) operator in JavaScript.

## Javascript

 ``

Output:

```> true
> false
> false
> false
> true```

Example 2: This example describes the inequality operator to compare the 2 values.

## Javascript

 ``

Output:

```> false
> true
> false
> true
> false```

Strict equality(===):  This operator is used to compare the equality of two operands with type. If both value and type are equal then the condition is true otherwise false.

Syntax:

`x === y`

Example 1: Below examples illustrate the (===) operator in JavaScript.

## Javascript

 ``

Output:

```> false
> true
> true
> false
> false```

Example 2: This example describes the strict equality operator to compare the 2 values.

## Javascript

 ``

Output:

```> true
> false
> true
> false
> false```

Please refer to the ‘===’ vs ‘==’ Comparison Operator article for the significant differences in them.

Strict inequality(!==): This operator is used to compare the inequality of two operands with type. If both value and type are not equal then the condition is true otherwise false.

Syntax:

`x !== y`

Example 1: Below examples illustrate the (!==) operator in JavaScript.

## jscript

 ``

Output:

```> true
> false
> false
> true
> true```

Example 2: This example describes the strict inequality operator to compare the 2 values.

## Javascript

 ``

Output:

```> false
> true
> false
> true
> true```

Relational Operators:

Greater than operator(>):  This operator is used to check whether the left-side value is greater than the right-side value. If the value is greater then the condition is true otherwise false.

Syntax:

`x > y`

Example 1: Below examples illustrate the (>) operator in JavaScript.

## Javascript

 ``

Output:

```> true
> true
> false
> true```

Example 2: This example describes the greater than operator to compare the 2 values.

## Javascript

 ``

Output:

```> true
> false
> false
> false
> true```

Greater than or equal operator(>=): This operator is used to check whether the left side operand is greater than or equal to the right side operand. If the value is greater than or equal then the condition is true otherwise false.

Syntax:

`x >= y`

Example 1: Below examples illustrate the (>=) operator in JavaScript.

## Javascript

 ``

Output:

```> true
> true
> true
> false```

Example 2: This example describes the greater than or equal operator to compare the 2 values.

## Javascript

 ``

Output:

```> true
> true
> false
> true
> true```

Less than operator(<): This operator is used to check whether the left-side value is less than the right-side value. If yes then the condition is true otherwise false.

Syntax:

`x < y`

Example 1: Below examples illustrate the (<) operator in JavaScript.

## Javascript

 ``

Output:

```> true
> false
> false
> true```

Example 2: This example describes the Less than operator to compare the 2 values.

## Javascript

 ``

Output:

```> true
> false
> true
> false
> false```

Less than or equal operator(<=): This operator is used to check whether the left side operand value is less than or equal to the right side operand value. If yes then the condition is true otherwise false.

Syntax:

`x <= y`

Example 1: Below examples illustrate the (<=) operator in JavaScript.

## Javascript

 ``

Output:

```> true
> false
> false
> true```

Example 2: This example describes the Less than or equal to an operator to compare the 2 values.

## Javascript

 ``

Output:

```> true
> true
> true
> true
> false```

Supported Browsers: The browsers supported by all JavaScript Comparison operators are listed below: