[英]Iterating over non-enumerable properties
I have used Object.defineProperty
and enumerable: false
to define a few properties on a config object.我使用Object.defineProperty
和enumerable: false
在配置 object 上定义一些属性。 There is however one place in my module where I would like to iterate over the non-enumerable properties as well as the enumerable ones.然而,在我的模块中有一个地方我想迭代不可枚举的属性以及可枚举的属性。 Is it possible to do this without keeping a list of property names elsewhere?是否可以在不保留其他地方的属性名称列表的情况下做到这一点?
I guess you could use getOwnPropertyNames
which returns properties, enumerable or not. 我想你可以使用getOwnPropertyNames
返回属性,可枚举与否。
From the docs: 来自文档:
Returns an array of all properties (enumerable or not) found directly upon a given object. 返回直接在给定对象上找到的所有属性(可枚举或不可枚举)的数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.