Async/Await
async function firstAsync () { return 27 //return Promise.resolve(27) } firstAsync().then(val => { console.log(val) }) console.log(firstAsync() instanceof Promise) //true async function fun () { let promise = new Promise((resolve,reject) => { setTimeout(function () { resolve(‘now it is done‘) },1000) }) console.log(await promise) console.log(await Promise.resolve(40)) console.log(2) return Promise.resolve(3) } fun().then(val => { console.log(val) })
相关推荐
89500297 2020-06-07
陈旭阳 2020-06-02
前端开发Kingcean 2020-05-29
Magicsoftware 2020-03-28
Trustport 2019-12-16
85403263 2019-07-01
Bonrui编程路 2020-06-07
niehanmin 2020-05-19
Magicsoftware 2020-03-28
LorenLiu 2020-03-28
lyg0 2020-02-18
88520191 2020-01-30
csuzxm000 2020-01-10
whynotgonow 2020-01-05
89500297 2020-01-03
88520191 2019-12-30
wujiajax 2014-01-13