# JavaScript | Comparison operators

Operators are used to perform 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 statements to determine equality or difference between variables or values. There are various comparison operators supported by JavaScript:

• Equality Operators
• Relational Operators

### 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
```

Below examples illustrate the (==) operator in JavaScript:

Example 1:

## Javascript

 ``

Output:

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

Example 2:

## 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
```

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

Example 1:

## Javascript

 ``

Output:

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

Example 2:

## 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
```

Below examples illustrate the (===) operator in JavaScript:

Example 1:

## Javascript

 ``

Output:

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

Example 2:

## Javascript

 ``

Output:

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

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
```

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

Example 1:

## Javascript

 ``

Output:

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

Example 2:

## Javascript

 ``

Output:

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

## Relational Operators

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

Syntax:

```x > y
```

Below examples illustrate the (>) operator in JavaScript:

Example 1:

## Javascript

 ``

Output:

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

Example 2:

## Javascript

 ``

Output:

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

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

Syntax:

```x >= y
```

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

Example 1:

## Javascript

 ``

Output:

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

Example 2:

## Javascript

 ``

Output:

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

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

Syntax:

```x < y
```

Below examples illustrate the (<) operator in JavaScript:

Example 1:

## Javascript

 ``

Output:

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

Example 2:

## Javascript

 ``

Output:

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

Less than or equal operator  (<=): This operator is used to checks 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
```

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

Example 1:

## Javascript

 ``

Output:

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

Example 2:

## Javascript

 ``

Output:

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

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

• Firefox
• Opera
• Safari
• Edge
• Internet Explorer My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.