function *g1(){ yield 2; yield 3; } function *g2(){ yield 1; yield *g1(); yield 4; return 5; } var gen = g2(); for(let i of gen){ console.log(i); }