Program to use JavaScript Array keys() method
let a = ["JavaScript","Python","Php","Css","Html"];
let b = a.keys();
for(let key of b){
console.log(key);
}
Output
0
1
2
3
4
Steps Description
- Declare three variable
a, bandkey - Initialize three variable with value of array
a = ["JavaScript","Python","Php","Css","Html"], b = a.keys()andkey - Array
keys()method returns the index number of the given array. - The value of
keyvariable is displayed with the help of console.log inbuilt function
Program to use JavaScript Array keys() method
let a = ["JavaScript","Python","Php","Css","Html"];
let b = a.keys();
for(let key of b){
console.log(key);
}
Output
0
1
2
3
4
Steps Description
- Declare three variable
a, bandkey - Initialize three variable with value of array
a = ["JavaScript","Python","Php","Css","Html"], b = a.keys()andkey - Array
keys()method returns the index number of the given array. - The value of
keyvariable is displayed with the help of console.log inbuilt function