Iterator implementation has been updated to the latest spec

Published: | Categories: JavaScript

Description

The implementation of the iterator protocol and for...of loop has been updated to comply with the ECMAScript 6 spec (moving away from the SpiderMonkey legacy iterator protocol using StopIteration). The iterator method of the Array, Map, Set and String interfaces has been renamed to @@iterator. Previously, the next method of an iterator returned a value from the array (or a key-value pair from the object), and raised a StopIteration exception when the iteration was done. The next method now returns an object like { done: false, value: <em>value</em> } then returns { done: true, value: undefined } when the iteration is done.

References