javascript - Type casting when == used instead of === -
this question has answer here:
i don't prefer using == today experimenting following code including == , results bit confusing me. can please explain happening?
all these falsy values:
'', 0, false, undefined, null suppose did:
if (undefined == null) { alert('a'); } else { alert('b'); } the statements below give true:
null == undefined 0 == '' false == '' 0 == false but why code below return false?
undefined == 0 undefined == '' null == 0
because 0, false , '' "values" while null "absence of value" , undefined "absence of definition".
thus, can compare "values" each other, same "non-values". can't compare "values" "non-values".
Comments
Post a Comment