Non enumerable property

suggest change

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

The enumerable property of the property descriptor tells whether that property will be enumerated while looping through the object’s properties.

var obj = { };

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

for (var 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