Skip to content

Instantly share code, notes, and snippets.

Last active November 2, 2017 23:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
JavaScript Iterators: Strings, spread, and for of
/* JavaScript Iterators
Strings as data source; for of and spread operator as data consumers
Strings can be consumed as iterables using the spread operator.
Note that strings will be parsed according to code points, not by character,
and so num characters parsed will be somewhat nondeterministic.
1 - Axel Rauschmeyer:
2 -
let album = [...'OK Computer'];
let letterz = album.entries();
for( let letter of letterz ) {
console.log( letter );
/* output:
[2," "]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment