Problem Statement
What is the primary difference between == and === in JavaScript?
Explanation
The loose equality operator (==) allows type coercion before comparison, which can lead to surprising results.
The strict equality operator (===) checks both value and type without coercion and is generally safer in most comparisons.
Code Solution
SolutionRead Only
console.log(5 == '5'); // true (coercion) console.log(5 === '5'); // false (different types)
Practice Sets
This question appears in the following practice sets:
