The difference between null and undefined in JavaScript

It workers2022-06-23 18:05:52


Indicates that there is no object , That is, there should be no value , Usage is as follows :

As an argument to a function , The parameter representing the function is not an object ;

As the end of the prototype chain .


Indicates a lack of value , This is where there should be a value , But there is no definition , The situation is as follows :

Variables are declared , But when there is no assignment , Is equal to undefined;

When you call a function , The parameter that should be provided is not provided , This parameter is equal to undefined;

Object has no assigned property , The value of this property is undefined;

When the function does not return a value , Default return undefined;

Similar articles