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

Categories

图片描述

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...