码迷,mamicode.com
首页 > 其他好文 > 详细

Faster async functions and promises

时间:2019-09-27 21:10:14      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:com   ref   https   promise   ISE   href   foo   wait   ast   

 

https://v8.dev/blog/fast-async

 

async function computeAnswer() {
return 42;
}
undefined
const p = computeAnswer();

undefined
p.then(console.log);

42
Promise {<resolved>: undefined}

 

async function foo() {
const v = await 42;
return v;
}
undefined
const p = foo();

undefined
p.then(console.log);

42
Promise {<resolved>: undefined}

 技术图片

 

Faster async functions and promises

标签:com   ref   https   promise   ISE   href   foo   wait   ast   

原文地址:https://www.cnblogs.com/yuanjiangw/p/11600106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!