Non enumerable property

suggest change

We can keep a property from showing up in for (... in ...) loops.

The enumerable attribute of the property descriptor controls whether that property is visited. for...in walks enumerable properties of the object and of its prototype chain, and it skips non-enumerable properties.

const obj = { };

Object.defineProperty(obj, "foo", { value: 'show', enumerable: true });
Object.defineProperty(obj, "bar", { value: 'hide', enumerable: false });

for (const prop in obj) {
    console.log(obj[prop]);
}

Console output

show

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents