Skip to content

Instantly share code, notes, and snippets.

@brunos3d
Created November 12, 2021 14:53
Show Gist options
  • Save brunos3d/725aeb745b2c8bbda9d391be0de6b1cf to your computer and use it in GitHub Desktop.
Save brunos3d/725aeb745b2c8bbda9d391be0de6b1cf to your computer and use it in GitHub Desktop.
Javascript FOR OF with loop index.

Javascript FOR OF with loop index.

for (const [index, value] of [1, 2, 3, 4, 5].entries()) {
  console.log(index, value);
}
// => 0 1
// => 1 2
// => 2 3
// => 3 4
// => 4 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment