-Object properties can be own (the property is on the object itself) or inherited (not on the object itself, on one of its prototypes).
-Object properties can be enumerable or non-enumerable. Non-enumerable properties are left out of lots of property enumerations/arrays.
-Property names can be strings or Symbols. Properties whose names are Symbols are left out of lots of property enumerations/arrays.
-Here in 2018, your options for looping through an object's properties are (some examples follow the list):
- for-in [MDN, spec] — A loop structure that loops through the names of an object's enumerable properties, including inherited ones, whose names are strings
- Object.keys [MDN, spec] — A function providing an array of the names of an object's own, enumerable properties whose names are strings.
- Object.values [MDN, spec] — A function providing an array of the values of an object's own, enumerable properties.
- Object.entries [MDN, spec] — A function providing an array of the names and values of an object's own, enumerable properties (each entry in the array is a [name, value] array).
- Object.getOwnPropertyNames [MDN, spec] — A function providing an array of the names of an object's own properties (even non-enumerable ones) whose names are strings.
- Object.getOwnPropertySymbols [MDN, spec] — A function providing an array of the names of an object's own properties (even non-enumerable ones) whose names are Symbols.
- Reflect.ownKeys [MDN, spec] — A function providing an array of the names of an object's own properties (even non-enumerable ones), whether those names are strings or Symbols.
If you want all of an object's properties, including non-enumerable inherited ones, you need to use a loop and Object.getPrototypeOf [MDN, spec] and use Object.getOwnPropertyNames, Object.getOwnPropertySymbols, or Reflect.ownKeys on each object in the prototype chain (example at the bottom of this answer). With all of them except for-in, you'd use some kind of looping construct on the array (for, for-of, forEach, etc.).
https://stackoverflow.com/questions/684672/how-do-i-loop-through-or-enumerate-a-javascript-object