判断类型
常用判断类型
typeof
instanceOf
Object.prototype.toString.call()
判断是否是数组
Array.isArray
Array.prototype.isPrototypeOf()
Object.getPrototypeOf([]) === Array.prototype
判断对象是否为空
Object.keys().length
JSON.stringify() === '{}'
Object.getOwnPropertyNames().length
for/in
判断对象中是否存在某个属性
hasOwnProperty
in操作符
Reflect.has
Object.prototype.hasOwnProperty.call()
Object.hasOwn
Obejct.keys().includes