Seems to have seen null==undefined,null!==undefined before, but also has not cared.
Recently looked at someone else's program source code, everywhere have some such as if (x!=undefined&&x!=null&&x!= ""), such as judgment, suddenly feel written very long-winded, I generally direct if (x) {} because no matter null, Undefined, "" in the conditional judgment is in fact false, why should it be so verbose? (Note that if your x==0 is also valid, you cannot use the if (x) {} to make conditional judgments)
In order to prove this superfluous, I also deliberately did the following tests:
var A;
Alert (x)
if (x==null) {
Alert (' failed ')
}
where x is an uninitialized variable, that is, undefined.
Run the above code: successively pop-up undefined and failed, indicating that the x==null is eligible.
We can directly alert (null==undefined) can actually find the return of true.
It all means to x==null| | X==undefined or x!=null&&x!=undefined and so on are purely superfluous!
Generally you just have to judge null or undefined one.
Current 1/3 page
123 Next read the full text