for...in和Object.keys区别

2019-06-01  本文已影响0人  吴晗君
function Parent () {}
Parent.prototype.x = 1
const child = new Parent()

// []
Object.keys(child)
// 'x'
for (let k in child) {
  console.log(k)
}

// configurable: true
// enumerable: true
// value: 1
// writable: true
Object.getOwnPropertyDescriptor(Parent.prototype, 'x')
上一篇 下一篇

猜你喜欢

热点阅读