jskatas.org Continuously Learn JavaScript. Your Way.

Iterator: array

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.

the iterator

  • an array has an iterator, which is a function
  • can be looped with for-of, which expects an iterable

the iterator protocol

  • calling next() on an iterator returns an object according to the iterator protocol
  • the after-last element has done=true