The Object getOwnPropertyNames() method
By Flavio Copes
Learn how the JavaScript Object.getOwnPropertyNames() method returns all own property names, including non-enumerable ones that Object.keys() leaves out.
~~~
Object.getOwnPropertyNames() returns an array containing all the names of the own properties of the object passed as argument, including non-enumerable properties. It does not consider inherited properties.
Non enumerable properties are not iterated upon. Not listed in for..of loops, for example.
To get only a list of the enumerable properties you can use Object.keys() instead.
Example:
const dog = {}
dog.breed = 'Siberian Husky'
dog.name = 'Roger'
Object.getOwnPropertyNames(dog) //[ 'breed', 'name' ]~~~
Related posts about js: