javascript - Type casting when == used instead of === -


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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -