Skip to content

Instantly share code, notes, and snippets.

@segdeha
Created August 17, 2018 21:22
Show Gist options
  • Save segdeha/d041a8489c01393138d399cb69ed86e2 to your computer and use it in GitHub Desktop.
Save segdeha/d041a8489c01393138d399cb69ed86e2 to your computer and use it in GitHub Desktop.
`for of` versus `forEach`
let arr = ['a', 'b', 'c'];
for (const [i, x] of arr.entries()) {
console.log(i, x);
}
arr.forEach((x, i ) => {
console.log(i, x);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment