Null is a keyword in JS that represents a null value. Null can be thought of as a special value of type object, if the value of an object is null, indicating that the object is not a valid object. Null and 0 Here are not the same thing, in C + + The NULL is usually defined as 0, but not in JS.
Undefined is not a JS keyword, it is a global variable, that is, a property of global, 3 cases will return undefined:
1. An undefined variable is used;
2. A variable that has been defined but not assigned is used;
3. An object attribute is used, but the property does not exist or is assigned;
Although undefined and null are different, running the following code returns TRUE.
alert (undefined==null);
var v= ""; alert (v.a==null); alert (v.a=undefined);
This is because undefined and null represent worth missing, so here they are equivalent. But not exactly equal, the following code returns false.
alert (nudefined==null);