Slide 5
Slide 5 text
const arr = [1, 2, 3, 4, 5];!
!
function iterator(arr) {!
let currentIndex = 0;!
const { length } = arr;!
return {!
next() {!
return arr[currentIndex++];!
},!
done() {!
return length =< currentIndex;!
}!
}!
}!
const iter = iterator(arr);!
iter.next();!
iter.next();!