use index in foreach javascript code example
Example 1: javascript foreach index
users.forEach((user, index)=>{
console.log(index); // Prints the index at which the loop is currently at
});
Example 2: foreach javascript
var items = ["item1", "item2", "item3"]
var copie = [];
items.forEach(function(item){
copie.push(item);
});