JS: List Properties

By Xah Lee. Date: . Last updated: .

To list properties of a object, use one of the following methods. Which one to use depends on if you want enumerable keys only, and or including symbol keys.

Properties to Array
syntaxmeaningproto chainenumerable onlyinclude symbol keyinclude string key
Object.keys(o) [see JS: Object.keys] noyesnoyes
Object. getOwnPropertyNames(o) [see JS: Object.getOwnPropertyNames] nononoyes
Object. getOwnPropertySymbols(o) [see JS: Object.getOwnPropertySymbols] nonoyesno
Reflect.ownKeys(o) [see JS: Reflect.ownKeys] nonoyesyes

[see JS: Property Attributes, writable, enumerable, configurable]

Array-Like Object to Array

[see JS: Array-Like Object to Array]

Iterable Object to Array

If the object is iterable, use:

Array.from(iterable)

[see JS: Array.from]

Array Topic

  1. JS: Array Basics
  2. JS: Understand JS Array
  3. JS: Create Array
  4. JS: Sparse Array
  5. JS: Array-Like Object
  6. JS: Array How-To

  1. JS: Array Object
  2. JS: Array.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon