Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JavaScript Iterators

The iterator protocol specifies how to generate a sequence of values from an object.

An object qualifies as an iterator when it implements a next() method.

The next() method must return an object containing two properties:

  • value (the next value)
  • done (true or false)

value

The value returned by the iterator
(Can be omitted if done is true)

done

true if the iterator has completed
false if the iterator has produced a new value