# The Object getOwnPropertyNames() method

> Learn how the JavaScript Object.getOwnPropertyNames() method returns all own property names, including non-enumerable ones that Object.keys() leaves out.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2019-04-05 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/javascript-object-getownpropertynames/

`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()`](https://flaviocopes.com/javascript-object-keys/) instead.

Example:

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

Object.getOwnPropertyNames(dog) //[ 'breed', 'name' ]
```
