Non-standard. The Iterator function is a SpiderMonkey-specific feature, and will be removed at some point. For future-facing usages, consider using for..of loops and the iterator protocol.


The Iterator function returns an object which implements legacy iterator protocol and iterates over enumerable properties of an object.




Object to iterate over properties.


An overview of the usage is available on the Iterators and Generators page.

Returns next item in the [property_name, property_value] format. It throws StopIteration if there are no more items.


Iterating over properties of an object

var a = {
  x: 10,
  y: 20,
var iter = Iterator(a);
console.log(; // ["x", 10]
console.log(; // ["y", 20]
console.log(; // throws StopIteration

Iterating over properties of an object with legacy destructuring for-in statement

var a = {
  x: 10,
  y: 20,

for (var [name, value] in Iterator(a)) {
  console.log(name, value);   // x 10
                              // y 20


Non-standard. Not part of any current standards document.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support Нет (Да) Нет Нет Нет
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support Нет Нет (Да) Нет Нет Нет

See also

Метки документа и участники

 Внесли вклад в эту страницу: fscholz, teoli, yakovlevigorek
 Обновлялась последний раз: fscholz,