# Get the index in a JavaScript for-of loop

> Learn how to get the index of the current iteration in a JavaScript for-of loop by calling the array entries() method with destructuring syntax.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-11-07 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/how-to-get-index-in-for-of-loop/

A for-of loop, introduced in ES6, is a great way to iterate over an array:

```js
for (const v of ['a', 'b', 'c']) {
  console.log(v)
}
```

How can you get the index of an iteration?

The loop does not offer any syntax to do this, but you can combine the destructuring syntax introduced in [ES6](https://flaviocopes.com/es6/) with calling the `entries()` method on the array:

```js
for (const [i, v] of ['a', 'b', 'c'].entries()) {
  console.log(i, v)
}
```
