JS: List Properties
Object Properties to Array
- To list properties of a object, use one of the following methods.
- They return a Array or Iterable. Then you can loop over them
| Method | include non-Enumerable keys | include Symbol key | include string key |
|---|---|---|---|
| Object.keys | no | no | ✅ |
| Object.values | no | no | ✅ |
| Object.entries | no | no | ✅ |
| Object.getOwnPropertyNames | ✅ | no | ✅ |
| Object.getOwnPropertySymbols | ✅ | ✅ | no |
| Reflect.ownKeys | ✅ | ✅ | ✅ |
Array-Like Object to Array
Iterable Object to Array
Loop Over Enumerate Properties Over Prototype Chain
| syntax | use proto chain | include non-Enumerable keys | include Symbol Key | include string key |
|---|---|---|---|---|
| for-in Loop | ✅ | no | no | ✅ |