Copyright 2025

The Valley of Code

A Flavio Copes project

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

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' ]

Want to master TypeScript? Check out my TypeScript Masterclass

Join my AI Workshop !

The Web Development BOOTCAMP cohort starts in February 2026