04. Array Iteration
for-in loop
for-in loopconst colors = ["red", "green", "blue"];
for (const index in colors) {
console.log(colors[index]);
}for loop
for loopconst colors = ["red", "green", "blue"];
for (const i = 0; i < colors.length; i++) {
console.log(colors[i]);
}forEach function
forEach functionconst colors = ["red", "green", "blue"];
colors.forEach((item, index, array) => {
console.log(item, index);
});for..of loop
for..of looparr.entries()
arr.entries()arr.values()
arr.values()arr.keys()
arr.keys()Last updated