Object.keys(), Object.values() & Object.entries() in JavaScript

CodeyMaze
Mar 5, 2022

--

Objects are used to store the data in the form of key-value pairs. Javascript provides us with some methods that we can use to retrieve the keys, values, or entries.

Object.keys()

Object.keys() method is used to get all the keys of an object by passing the object as a parameter to this function.

Syntax :

Object.keys(<objectname>)

Output :

Object.values()

Object.values() method is used to get all the values of an object by passing the object as a parameter to this function.

Syntax :

Object.values(<objectname>)

Output :

Object.entries()

Object.entries() returns an array of key-value pairs where the first element will be the property name of the passed object and the second element will be the value of the property of the passed object.

Syntax :

Object.entries(<objectname)

Output :

Subscribe to our Youtube channel for more videos :

https://www.youtube.com/channel/UCEXWe9R6-ppk4zhNo2JbtmQ

--

--

CodeyMaze
CodeyMaze

Written by CodeyMaze

Crafting Solutions Through Code & Words https://codeymaze.com Feel free to follow me :)

No responses yet