# Built-in keys iterator in JavaScript

All iterables have the built-in `keys` iterator that allows you to iterate over keys. Let's test it on an array:

`let arr = ['a', 'b', 'c'];`

We get an iterator:

`let iter = arr.keys();`

And loop through it:

`for (let elem of iter) { console.log(elem); // 0, 1, 2 }`

Test the work of this iterator on a `Map` collection.

Test the work of this iterator on a `Set` collection.

←→
↑
en ru