async、genorator、callback的介绍及对比
async函数和genorator函数
总述:Async函数就是genorator函数的语法糖,他是genorator函数+一个自动执行器,包含在一个函数里。
1.genorator函数
这里概念就不多说了,为了解决异步编程的方法之一,我直接上代码
请复制以下代码到编辑器中运行或查看,会更加清晰
function base(){
console.log(‘hello1’)
}
const fn = function* (){
let res = yield base()
console.log(‘res’,
原创
2020-08-03 10:10:40 ·
2126 阅读 ·
0 评论