Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

es6 书上看见的 不太懂问问大神

图片描述

这是我在书上看见的 真心没见过这么写的?我是说 为什么函数那边必须写

“*” 还有就是 那个 yield 是干什么的?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

*表示这是generator函数,翻译过来就是生成器yield表示函数在此暂停,执行异步操作。是es6解决异步编程的方案,让我们能用同步的思维来编写异步的代码。

具体可参考。关于异步编程,可以看看阮一峰的系列文章


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...