How to use JavaScript Object keys()
Object keys
On this page
Object keys() Method
Program to use JavaScript Object keys() method
let player = {
name: "Cristiano Ronaldo",
age: "38",
game: "football",
};
let a = Object.keys(player);
console.log(a);
Output
[ 'name', 'age', 'game' ]
Steps Description
- Declare two variable Object variable and variable player and a
- Initialize two variable Object variable and variable player and a with value of Object player = {name: “Cristiano Ronaldo”,age: “38”,game: “football”,}; and a
- The Object key() method outputs the given object into an array.
- The value of a variable is displayed with the help of console.log inbuilt function