Answers for "js loop array index"

2

js for of array with index

for (const [index, value] of [1, 2, 3, 4, 5].entries()) {
  console.log(index, value);
}
Posted by: Guest on June-18-2021
2

js iterate array index

for (let [index, val] of array.entries()) {
        // your code goes here    
}
Posted by: Guest on May-16-2021
11

javascript foreach index

users.forEach((user, index)=>{
	console.log(index); // Prints the index at which the loop is currently at
});
Posted by: Guest on June-19-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language