Explain, please, what are enumerable and non-enumerable properties? Faced them here:

The propertyIsEnumerable() method imposes additional restrictions compared to hasOwnProperty() . It returns true only if the specified property is a property of its own, whose enumerable attribute is true . Properties of embedded objects are not enumerated. Properties created by a regular JavaScript program are enumerated if one of the ECMAScript 5 methods presented below, which make the properties non-enumerable, was not used.

 var o = inherit({ y: 2 }); ox = 1; o.propertyIsEnumerable("x"); // true: o имеет собств. перечислимое свойство x o.propertyIsEnumerable("y"); // false: y - унаследованное свойство, не собств. Object.prototype.propertyIsEnumerable("toString"); // false: неперечислимое 

(c) David Flanagan "JavaScript. Detailed Guide", 6th edition, p. 148

From these lines it turns out that:

  • Non-enumerable properties are properties of embedded objects. Here you should clarify what are embedded objects: these are Array , Boolean , Date , Error , Function , Global , JSON , Math , Number , Object , RegExp and String objects.
  • Enumerated properties are properties created by a regular program. It is from this context that the properties assigned to the object by the assignment operator = , without any inheritance (own properties):

      ox = 1 // Объекту "o" присвоенно свойство "x" со значеним "1" 

    those. non-enumerable property will be in the case of inheritance, and if it is a property of an embedded object.

While writing, as if figured out. Correct me if I am mistaken.

  • In general, yes, if the property is inherited or embedded, it is not enumerated. Plus, this property can obviously not be enumerated: stackoverflow.com/questions/10968962/… And you have a good book. And who said it would be easy. programming and layout are completely different things. Yes, and JS is not the easiest language. And a deep understanding after one book is unlikely to come. here experience is needed. Understanding variables and functions is enough to do basic things, which you should already try to do - Mike

2 answers 2

There is a for each cycle, which allows you to loop through all the properties of an object in a loop and, accordingly, do something else with them. So, this can be done only with the enumerated properties of the object.
David Flanagan JavaScript. Detailed guide, 6th edition - is considered the best book on JS. I can advise you codeacademy. There are great courses on js. In practice, you should see everything.

  • still for..in - Grundy

Complicated tutorial? - go through this: https://learn.javascript.ru/

And about your question, those properties are not iterated, which are in the prototype. But you can set individual parameters using Object.defineProperty . You can read more about it here: https://learn.javascript.ru/descriptors-getters-setters

  • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky