1

In order to be iterable, an object must implement the @@iterator method, meaning that the object (or one of the objects up its prototype chain) must have a property with a Symbol.iterator key:

Source.

What does the @@ prefix indicate here? Does this mean that iterables must have a method on their prototype chain with a name corresponding to the Symbol.iterator value?

j08691
  • 204,283
  • 31
  • 260
  • 272
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
  • 1
    *"Does this mean that iterables must have a method on their prototype chain with a name corresponding to the `Symbol.iterator` value?"* They have to implement a property whose property name *is* the value of `Symbol.iterator`. Is that what you meant? – Felix Kling Oct 28 '15 at 18:39
  • Yes and I presume the corresponding property value must be a function object with a well defined API? – Ben Aston Oct 28 '15 at 18:41
  • Yes. The function has to return an object that implements the iterator protocol, as explained in article you linked to (or I guess it's actually not that explicit). – Felix Kling Oct 28 '15 at 18:42
  • I realized it's the same link you posted. – Felix Kling Oct 28 '15 at 18:45

0 Answers0