当前位置:网站首页>Promise.race学习(判断多个promise对象执行最快的一个)
Promise.race学习(判断多个promise对象执行最快的一个)
2022-08-11 05:25:00 【陈阳羽】
Promise.race学习
<script>
/* Promise.race学习 1.语法:Promise.race(一个包含多个Promise对象的数组) 2.返回一个新的Promise对象 改对象是第一个完成Promise的状态 注释:在这里可以调整setTimeout的延时来试验Promise.race */
var a =new Promise((resolve,reject)=>{
setTimeout(() => {
resolve("2s");
}, 2000);
})
var b =new Promise((resolve,reject)=>{
setTimeout(() => {
reject('1s')
}, 3000);
})
var race=Promise.race([a,b])
console.log(race)
</script>
边栏推荐
猜你喜欢
STM32学习笔记(白话文理解版)—小灯的点亮、闪烁、呼吸
珍爱网App竞品分析报告
Robust 3D Object Detection in Cold Weather Conditions
目标检测前言
STM32学习笔记(白话文理解版)—外部IO中断实验
自定义形状seekbar学习
Severe Weather 3D Object Detection Dataset Collection
Toward a Unified Model
Wisdom construction site safety helmet identification system
STM32F407-浅~~析UART异步通信&USART_Init函数入口参数
随机推荐
STM32学习笔记(白话文理解版)—按键控制
10 个超好用的 DataGrip 快捷键,快加入收藏! | 实用技巧
AI-based intelligent image recognition: 4 different industry applications
Diagnostic Log and Trace——开发人员如何使用 DLT
Error: Flash Download failed - “Cortex-M4“-STM32F4
梅科尔工作室-华为云ModelArts第一次培训
支付牌照是什么意思
arduino的esp32环境搭建(不需要翻墙,不需要离线安装)
跨应用间调用: URL Scheme
梅科尔工作室-DjangoWeb 应用框架+MySQL数据库第二次培训
STM32-库函数-SetSysClock(void)函数解析-正点原子探索者
The selection points you need to know about the helmet identification system
弱监督语义分割CLIMS(CVPR2022)
产品经理的基础知识
张小龙的微信公开课(2019年)
我心仪的数据集—目标检测为主
mAPH - Waymo dataset
关于mmdetection框架实用小工具说明
Use regex to verify whether the file name is legal
梅科尔工作室-华为云ModelArts第二次培训