Path: blob/main/files/en-us/web/javascript/reference/operators/inequality/index.md
6532 views
------{{jsSidebar("Operators")}}
The inequality (!=) operator checks whether its two operands are not equal, returning a Boolean result. Unlike the strict inequality operator, it attempts to convert and compare operands that are of different types.
{{EmbedInteractiveExample("pages/js/expressions-inequality.html")}}
Syntax
Description
The inequality operator checks whether its operands are not equal. It is the negation of the equality operator so the following two lines will always give the same result:
For details of the comparison algorithm, see the page for the equality operator.
Like the equality operator, the inequality operator will attempt to convert and compare operands of different types:
To prevent this, and require that different types are considered to be different, use the strict inequality operator instead:
Examples
Comparison with no type conversion
Comparison with type conversion
Comparison of objects
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}