Strict equality === and !==
`===` gives `true` only when both values have the same type and the same value, with no conversion.
a === b compares two values and returns a boolean. a !== b is the opposite: true when they differ.
The key is that it doesn't convert types. "1" === 1 is false because one is a string and the other a number. The old == operator does convert, and that brings surprises like "" == 0 being true. That's why the course always uses ===.
With objects and arrays, === compares the reference, not the content: two arrays with the same items are different if they are two separate arrays.
One special case: NaN === NaN is false. Use Number.isNaN for that.
In TypeScript, if you compare types that can never match, the type checker warns you before the code runs.
Reach for it when: you need to ask whether two values are equal or different, for example in an `if`.
Examples
Common mistake
const id: number = 1; const input: string = "1"; console.log(id === input);
Why: A number and a string can never be `===`, so TypeScript warns you: the comparison would always be `false`.
How to write it: Convert first: id === Number(input).
Common mistake
const value: number = Number("abc");
console.log(value === NaN);Why: `NaN` is not equal to anything, not even itself, so that comparison is always `false`.
How to write it: Use Number.isNaN(value).
