The "==" operator compares values for equality, after doing any necessary type conversions.
The "===" operator, on the other hand, compares both value and type, and will only return true if the value and type match. In general, it is recommended to use the "===" operator, as it is less prone to unexpected behavior caused by type coercion.
For Example :
0 == false // true
0 === false // false
1 == "1" // true
1 === "1" // false
null == undefined // true
null === undefined // false
'0' == false // true
'0' === false // false
[]==[] or []===[] //false, refer different objects in memory
{}=={} or {}==={} //false, refer different objects in memory
Top comments (0)