- What is this?
- https://qiita.com/kura07/items/cf168a7ea20e8c2554c6
-
When the
[Symbol.iterator]()
method is executed, it returns an iterator.- What is Symbol?
- It seems that each time iterator.next() is called, the next value is returned.
- If an object follows the protocol of this Iterator,
- you can write
for (var v of obj) { do something }
- Spread Operator also supports iterators.
- Oh, so arrays and strings also have iterators.
- And you can write the same way with custom classes, which is nice.
- you can write
-
- What is Generator?