JavaScript has both strict and type–converting comparisons.
1- Strict comparison (
===
) : is True if the operands are of the same type and the contents match.2- Type–converting comparisons ( == ) : converts the operands to the same type before making the comparison.
Briefly :
-------------------------------------
==
only compares values===
compares values + type
----------------------------------
0 == false // true
0 === false // false, because they are of a different type
1 == "1" // true, automatic type conversion for value only
1 === "1" // false, because they are of a different type
null == undefined // true
null === undefined // false
'0' == false // true
'0' === false // false
No comments:
Post a Comment