in 和 hasOwnProperty(..) 的区别在于是否查找 [[Prototype]] 链
in 操作符会检查属性是否在对象及其 [[Prototype]] 原型链中。
hasOwnProperty() 只会检查属性是否在 myObject 对象中,不会检查 [[Prototype]] 链。
Object.keys() 和 Object.getOwnPropertyNames() 都只会查找对象直接包含的属性
...
原创
2020-12-11 16:23:57 ·
132 阅读 ·
0 评论