jskatas.org Continuously Learn JavaScript. Your Way.

Iterator: string

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

string is iterable

  • the strings object key Symbol.iterator` is a function
  • use Array.from() to make an array out of any iterable

a string`s iterator

  • has a special string representation
  • iterator.next() returns an object according to the iterator protocol
  • the after-last call to iterator.next() says done=true, no more elements