for in 可以用来枚举对象,默认行为是会枚举对象自己和原型链上所有可枚举的属性。所以一般要用Object.hasOwnProperty进行过滤。
通过Object.getOwnPropertyDescriptor(对象,属性)可得到对象属性的描述符,enumerable:为true的会打印出来。所以把他过滤掉
var a=[1, 2, 3, 4, 5, 6];
Object.getOwnPropertyDescriptor(a.__proto__,"has")
Object {writable: true, enumerable: true, configurable: true}