Object.keys() / values() / entries()
Returns keys, values, or pairs as arrays.
Syntax
Object.keys(object) · Object.values(object)
Description
keys provides the array of keys, values provides the array of values, entries provides [key, value] pairs.
Example
Loading editor…
Expected output
[ 'a', 'b' ] [ 1, 2 ]
When to use?
Iterating through all fields of an object with a loop.