Getting all the object entries
Getting key-value pairs of an object using Object.entries()
The Object.entries()
method returns an array of key-value pairs for each element in the object.
Usecases
- If you want to determine the number of key-value pairs in an object, you can use the
Object.entries()
method.
- If you want to get the keys of an object then you can use the
Object.entries()
method.
- If you want to get the
values
of an object then you can use theObject.entries()
method.
- If you want to check if an object has a specific key then you can use the
Object.entries()
method.
If youβre wondering why we can use array methods with Object.entries()
, remember that the Object.entries()
method returns an array of key-value pairs. We can then apply methods like map()
, some()
, and length
to this array to access or manipulate its values.