jsvarp=function*(){yield"1";console.log(2);}vart=p();varvalue=t.next();t.next();console.log(value);为什么这里yield只有一个却可以要调用两次next才能done呢?
2 回答
翻阅古今
TA贡献1780条经验 获得超5个赞
试下这几段代码的运行结果,就是@Honwhy给的结论。1、javascript'usestrict';function*fibonacci(){console.log("hello");}letseq=fibonacci();2、javascript'usestrict';function*fibonacci(){console.log("hello");}letseq=fibonacci();seq.next();3、javascript'usestrict';function*fibonacci(){yield;console.log("hello");}letseq=fibonacci();seq.next();seq.next();
添加回答
举报
0/150
提交
取消