The property of an object must be enumerable if you want to have access to it when re-executing all the properties of objects. Example:
var obj = {prop1: 'val1', prop2:'val2'}; for (var prop in obj){ console.log(prop, obj[prop]); }
In this type of instantiation, the enumerable is always true, this will give you the result:
prop1 val1 prop2 val2
If you used Object.create () as follows:
obj = Object.create({}, { prop1: { value: 'val1', enumerable: true}, prop2: { value: 'val2', enumerable: false} });
your for loop will only have access to prop1, not prop2. Using Object.create (), properties are set with enumerable = false by default.
source share