javascript array for loop index code example
Example 1: js iterate array index
for (let [index, val] of array.entries()) {
// your code goes here
}
Example 2: javascript for loop return index
const targetindex = myarray.findIndex(item => item.name === 'xyz');