!= operator

The inequality operator (!=) is the logical opposite of the equality operator. It means “Not Equal” and returns true whereas equality would return false and vice versa. Like the equality operator, the inequality operator will convert data types of values while comparing.

For example 1 != ‘1’ will return false since data type conversion takes place so 1 and ‘1’ are considered equal.

Example: Below example shows != Operator.

Javascript




console.log(" 1 != '1' " + (1 != '1'));
console.log(" 1 != 1 " + (1 != 1));
console.log(" 1 != '2' " + (1 != '2'));


Output

 1 != '1' false
 1 != 1 false
 1 != '2' true

Difference between != and !== operator in JavaScript

Similar Reads

!= operator

The inequality operator (!=) is the logical opposite of the equality operator. It means “Not Equal” and returns true whereas equality would return false and vice versa. Like the equality operator, the inequality operator will convert data types of values while comparing....

!== operator

...

Difference between != and !== operator in JavaScript

The strict inequality operator (!==) is the logical opposite of the strict equality operator. It means “Strictly Not Equal” and returns true whereas strict equality would return false and vice versa....

Contact Us