Skip to content

Instantly share code, notes, and snippets.

@toboid
Created August 21, 2023 12:27
Show Gist options
  • Select an option

  • Save toboid/cf28218494c52294f3d79bd8e57a53df to your computer and use it in GitHub Desktop.

Select an option

Save toboid/cf28218494c52294f3d79bd8e57a53df to your computer and use it in GitHub Desktop.
Index in a JS for...of loop
const arr = [1, 8, 3, 9];
for (const [i, element] of arr.entries()) {
// i is the index
// element is the array element
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment