June 6, 2023
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
anda
- Initialize two variable Object variable and variable
player
anda
with value of Objectplayer = {name: "Cristiano Ronaldo",age: "38",game: "football",};
anda
- 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
by : Suhel Akhtar
Quick Summary:
Get all the player keys using the JavaScript object keys() method