Most programming languages typically have a value that says "None", while JS has two, null, and undefined. So I looked up some information and summarized it here for inspection.
There are two major classes of variables in JS, basic value types, and reference types. Where the value type is divided into: undefined,null,number,bolean,string five kinds. Visible null and undefined are different types.
a) undefined
The appearance of undefined generally has the following situations:
1 variable declaration but not initialized.
The property of the 2 object is not assigned a value.
3 When a function is called, the default parameter is undefined.
4 when the function does not return a value, undefined is returned by default.
As can be seen from the above, when a variable or property is not initialized, the default value is undefined, so you do not need to display the setting of a variable with a value of undefined. At this point, you will want to do not need to display settings, why should he??? In fact it's just to differentiate between null object pointers (NULL) and uninitialized variables.
b) NULL
Null represents an empty object pointer, which stores an object that does not already exist. So this is the reason why you return "object" when you use the typeof operator to detect null. (typeof returns a string and the first letter is lowercase)
It is necessary to set the value to NULL if it is not necessary to display the setting variable value to undefined, and if the declared variable is used to represent the object and is not actually saved, it should be set to null.
Also, undefined is derived from null, so the return is true when "= =" is used.
null and undefined in JS