Difference between null and undefined in JS

Unset: When the declaration variables are not initialized, the default value of the variable is unset.

The NULL type has only one value, which is NULL. NULL is used to indicate an object that does not exist yet, which is often used to represent a function that attempts to return an unwanted object.

be reset

typeof(re); // The return result is undefined

typeof(null); // return result – object

The NULL data type is an Object object, so the five basic JS data types are String, Boolean, Numeric, Null, Undefined


NULL means “there is no object”, that is, it must be, it must be valuable. Typical use:

(1) As a function parameter, the function parameter is not an object.

(2) The end of the object’s parent string.



(1) Variables are declared, but in the absence of assignment, they are declared.

(2) When calling the function, the required parameters are not provided. This parameter is not specified.

(3) There is no object attribute, the attribute value is not specified.

(4) When the function does not return a value, undefined is returned by default.


var i;

Leave a Comment