JS: List Properties (to array)
Object properties to array
- To list properties of a object, use one of the following methods.
- They return a Array. 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
for-in loop
| syntax | use proto chain | include non-Enumerable keys | include Symbol Key | include string key |
|---|---|---|---|---|
| for-in loop | ✅ | no | no | ✅ |