When I am using any one of values(null, undefined, false, '', 0) in a if statement, it is always evaluated as fallacy(false). Also, the negation of these values((null, undefined, false, '', 0) in a if statement always evaluated as tautology(true).
if(null){
}else{
}
if(undefined){
}else{
}
if(false){
}else{
}
if(''){
}else{
}
if(0){
}else{
}
In all the above cases, if statement is evaluated as false & else statement executes.
However, when I am comparing these fallacy values with == operator, it is not returning true always. Surprisingly, it is always returning true values when I am comparing the negation of these values.
if double equalto (==) operator checks/compares for values & not strictly for types, then why:
null == false // returns false
null == 0 // returns false
null == '' // returns false
But,
!null == !false // returns true
!null == !0 // returns true
!false == !undefined // returns true
And,
null == undefined // returns true
false == 0 // returns true
I appreciate if any one can clarify the behavior or relationship among these values(null, undefined, false, '', 0).