Skip to content

Instantly share code, notes, and snippets.

@Ibro Ibro/iterators-array.js
Last active Apr 26, 2017

Embed
What would you like to do?
JavaScript Iterators - Array - Coding Blast - www.codingblast.com
let numbers = [1, 2, 3];
let it = numbers[Symbol.iterator]();
console.log(it.next()); // {value: 1, done: false}
console.log(it.next()); // {value: 2, done: false}
console.log(it.next()); // {value: 3, done: false}
console.log(it.next()); // {value: undefined, done: true}
for (let num of numbers) {
console.log(num);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.