InterviewBuddy
All interview questions

What is the difference between == and ===?

Beginner

Answer

Strict equality (===) compares without converting operands to a common type. Loose equality (==) can coerce types according to language rules.

Explanation

Prefer strict equality for predictable application code. Both operators compare objects by reference, not by deep structure.

Example

0 === "0" // false; 0 == "0" // true