wheresrhys
wheresrhys

Reputation: 23560

Iterating over non-enumerable properties

I have used Object.defineProperty and enumerable: false to define a few properties on a config 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?

Upvotes: 15

Views: 2837

Answers (1)

plalx
plalx

Reputation: 43728

I guess you could use getOwnPropertyNames which returns properties, enumerable or not.

From the docs:

Returns an array of all properties (enumerable or not) found directly upon a given object.

Upvotes: 19

Related Questions