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

  1. Declare three variable a, b and key
  2. Initialize three variable with value of array
    a = ["JavaScript","Python","Php","Css","Html"], b = a.keys() and key
  3. Array keys() method returns the index number of the given array.
  4. The value of key variable 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

  1. Declare three variable a, b and key
  2. Initialize three variable with value of array
    a = ["JavaScript","Python","Php","Css","Html"], b = a.keys() and key
  3. Array keys() method returns the index number of the given array.
  4. The value of key variable is displayed with the help of console.log inbuilt function