# Iterators

* Map/Set have methods (entries(), keys(), values()) that return iterator
* Provides sequential access to items
* Keep track of which item been accessed
* Iteretaor are object with a next() method
* next() return object with property value & done
* value - current value
* done - boolean indicates whether their is more item

## Set Iterator Demo

```javascript
new Set([1,2,3]).entries().next();
// Object {value: Array[2], done: false}
new Set([1,2,3]).entries().next().value // [1, 1]
new Set([1,2,3]).entries().next().done // false
```

## Map Iterator Demo

```javascript
var mapEntries = new Map([['one', 1], ['two', 2]]).entries();

mapEntries // MapIterator {["one", 1], ["two", 2]}
mapEntries.next() // Object {value: Array[2], done: false}
mapEntries.next() // Object {value: Array[2], done: false}
mapEntries.next() // Object {value: undefined, done: true}
```
