js null 和 undefined

undefined是一个特殊类型,null本质上是一个对象

typeof undefined
//"undefined"
typeof null
//"object"

什么情况会得到undefined?
(1)声明变量但没赋值。
(2) 函数的形参没传时,形参是。
(3)对象中没赋值的属性。
(4)函数没有返回值时,返回undefined

对象原型链的终点是null

Object.getPrototypeOf(Object.prototype)

// null

原文地址:https://www.cnblogs.com/lzs-888/p/6123195.html