Object getOwnPropertyNames() method

Find all information about the JavaScript getOwnPropertyNames() method of the Object object

Object.getOwnPropertyNames()Returns an array containing all namesmy ownThe properties of the object passed as a parameter include non-enumerable properties. It does not consider inherited attributes.

Properties that are not iterable will not be iterated. For example, it is not listed in the for..of loop.

To get only the list of enumerable properties, you can useObject.keys()instead.


const dog = {}
dog.breed = 'Siberian Husky'
dog.name = 'Roger'

Object.getOwnPropertyNames(dog) //[ ‘breed’, ‘name’ ]

Download mine for freeJavaScript beginner's manual

More js tutorials: