In JavaScript, !== is the strict inequality operator. It returns true when two values differ in value or in type, and false only when they are strictly equal. It is the negation of === and never converts types, unlike the loose !=.
Use !== whenever you want to check that something is not equal to a specific value. It removes the type-coercion surprises of != and works the same way for primitives, objects and null.
a !== b is exactly !(a === b). Before comparing, JavaScript checks the types; if they differ, the result is true without any conversion.
Note the last line. A common mistake is to think false !== 0 is false because both are "falsy". Strict comparison ignores truthiness; a boolean is never strictly equal to a number.
For objects, arrays and functions, !== compares references, not contents.
To compare contents, compare fields yourself, serialise carefully, or use structuredClone plus a deep-equality helper from a library. Remember NaN !== NaN is true, because NaN is not equal to anything. Test for it with Number.isNaN(value) or Object.is.
| Expression | !== | != |
|---|---|---|
5 !== "5" | true | false |
0 !== false | true | false |
null !== undefined | true | false |
"" !== 0 | true | false |
1 !== 2 | true | true |
!= converts types first using the loose equality rules, so 5 != "5" is false. That makes results harder to predict, which is why linters such as ESLint's eqeqeq rule ask for !==. The one common exception is value != null, which is false only for null and undefined.
Guard clauses and filters read clearly with strict inequality.
The typeof x !== "undefined" form is safe even for undeclared variables, because typeof does not throw a ReferenceError. When comparing values that may arrive as strings (form fields, query parameters), convert first, for example Number(input.value) !== limit.
id !== "5" is always true if id is the number 5.!x === y, which negates x first. Write x !== y.!== to detect NaN; use Number.isNaN.date1 !== date2 is reference comparison. Compare date1.getTime() values.TypeScript checks strict comparisons at compile time. Comparing values whose types can never overlap is reported as an error, which catches typos early.
Pair this with ESLint's eqeqeq rule so != never reaches review. Narrowing also works with !==: after if (value !== undefined), TypeScript treats value as defined inside the block. This is the most common reason to prefer explicit !== null and !== undefined checks over truthiness tests, which also reject 0, "" and false.
It means "not strictly equal": the operands have a different value or a different type.
No. != converts types before comparing, !== does not. Prefer !==.
Each array literal creates a new object, and !== compares object references. Two distinct objects are never strictly equal.
Yes. Strings are compared by their characters, case-sensitively, so "a" !== "A" is true.
!== is the strict inequality operator: it returns true when value or type differ, with no type coercion. It compares objects by reference, treats NaN as unequal to itself, and should be your default over !=. Use Number.isNaN, deep comparison and explicit conversion where the plain operator is not enough.