const doSometing = t => {
return new Promise(resolve => {
setTimeout(() => {
resolve(t);
}, t);
});
};
const doSometing2 = t => {
return t;
};
const fun = async () => {
let d3 = await doSometing2(2500);
console.log(d3); //不需要等待,直接输出2500
let d2 = await doSometing(1500); //阻塞1500毫秒后下面的代码才执行
console.log(d2); //1500
let d1 = await doSometing(1000); //阻塞1000毫秒后下面的代码才执行
console.log(d1); //1000
};
fun();
相关文章
- 01-05Django学习day2——Django安装与环境配置
- 01-05python虚拟环境virtualenv创建与迁移
- 01-05【DB笔试面试746】在O中,“...SWITCH LOGFILE”与“... ARCHIVE LOG CURRENT”区别
- 01-05机器学习---吴恩达---Week3(离散问题与逻辑斯蒂回归)
- 01-05objective-c与c++的差异
- 01-05Program Files 与Program Files (x86)
- 01-05NAND Flash与eMMC的区别
- 01-05Tesla Model汽车架构与FSD供应链
- 01-05【b站 机器学习基础】三、批次batch与动量momentum
- 01-0521:动量与学习率衰减