// ⭐️ for-of: treats "holes" as undefined
for (const value of array) {}
for (const [index, value] of array.entries()) {} // with index
// ⭐️ forEach: ignores "holes"
arr.forEach(value => ...) // .forEach() method
Unlike the for-of loop, forEach()is aware ofsparse arrays and does not invoke the function for nonexistentelements.