The Object.keys() method returns an array of a given object’s own enumerable properties, in the same order as that provided by a for…in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).
意思是说Object.key()返回一个数组不会遍历原型链上的键值,而for…in…会遍历原型链上的键值。
本文探讨了JavaScript中Object.keys方法与for...in循环之间的关键区别:Object.keys仅返回对象自身可枚举属性的键名数组,而for...in还会包括原型链中的属性。

3558

被折叠的 条评论
为什么被折叠?



