Answers for "js array get index in for loop"

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

javascript for loop return index

const targetindex = myarray.findIndex(item => item.name === 'xyz');
Posted by: Guest on June-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language