How to get the index of array elements in for loop with JavaScript

1 Answer

0 votes
const array = ['javascript','php','java','c++'];

for (const [index,value] of array.entries()) {
    console.log(index,value);
}
   
   
       
       
/*
run:
   
0, "javascript"
1, "php"
2, "java"
3, "c++"
   
*/
  

 



answered Jun 14, 2021 by avibootz
...