Skip to content

Instantly share code, notes, and snippets.

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