class
IterableClass
{
[
Symbol
.
iterator
]()
{
···
}
}
Several special methods in ECMAScript 6 have keys that are symbols. Computed method names allow you to define such methods. For example, if an object has a method whose key is Symbol.iterator
, it is iterable. That means that its contents can be iterated over by the for-of
loop and other language mechanisms.
ref