The difference between null and undefined in JavaScript

It workers 2022-06-23 18:05:52 阅读数:639

differencenullundefinedjavascript

1、null

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 .

2、undefined

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;

版权声明:本文为[It workers]所创,转载请带上原文链接,感谢。 https://qdmana.com/2021/12/202112311949066217.html