Inequality
suggest changeThe loose inequality operator (!=) is the inverse of the loose equality operator (==). It performs the same type coercion as ==, then negates the result. Prefer strict inequality (!==) unless coercion is intentional.
1 != "1"; // false: the string is converted to a number
1 != 2; // true
When both sides are objects, they are compared by identity, not by their contents:
({}) != ({}); // true: these are two distinct objects
The strict inequality operator (!==) is the inverse of strict equality (===). It returns true when the values have different types or are not strictly equal:
1 !== "1"; // true
1 !== 2; // true
1 !== 1; // false
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents