1function* fibonacci() {
2 var a = yield 1;
3 yield a * 2;
4}
5
6var it = fibonacci();
7console.log(it); // "Generator { }"
8console.log(it.next()); // 1
9console.log(it.send(10)); // 20
10console.log(it.close()); // undefined
11console.log(it.next()); // throws StopIteration (as the generator is now closed)
12