js async01
2021-04-29 16:26
标签:div res get lin ons syn turn function resolved
// calling start at: 48 js async01 标签:div res get lin ons syn turn function resolved 原文地址:https://www.cnblogs.com/anch/p/12200394.htmlfunction resolveAfter2Seconds() {
return new Promise(resolve => {
setTimeout(() => {
resolve(‘resolved‘)
}, 2000)
})
}
async function asyncCall() {
console.log(‘calling start at: ‘ + new Date().getSeconds())
const result = await resolveAfter2Seconds()
console.log(result + ‘ at: ‘ + new Date().getSeconds())
}
asyncCall()
resolved at: 50
上一篇:js async04
下一篇:NODEJS的误打误撞