MDN wants to learn about developers like you:

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

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,