Skip to content

Instantly share code, notes, and snippets.

@Ibro
Last active April 26, 2017 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ibro/f18322fb0b4435dbf4f48ab0c0d232c2 to your computer and use it in GitHub Desktop.
Save Ibro/f18322fb0b4435dbf4f48ab0c0d232c2 to your computer and use it in GitHub Desktop.
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