javascript's way of determining whether a variable has a value


This example shows how javascript determines whether a variable has a value. Share with you for your reference. The specific analysis is as follows:

Such as:

var a = null;
var b = undefined;

These two cases count as no values

if(a !== null && a !== undefined) {
  //
}
//  Why not use it alone if(a !== null) { // }
var a;
a !== null; // true
//  Why not use it alone if(a !== undefined) { // }
var a = null;
a !=== undefined; // true

I hope this article has been helpful to your javascript programming.