当前位置:网站首页>ES: Promise的基本用法
ES: Promise的基本用法
2022-08-02 16:59:00 【amadeus_liu2】
let myRandom=Math.floor(Math.random() * 10 );
var workIsDone=new Promise(
(resolve,reject) =>{
if(myRandom<5){
resolve("finished......")
}
else{
reject("ongoing......")
}
}
)
workIsDone.then(function(value) {
console.log("ok: "+value)
}, function(error) {
console.log("error: "+error);
});
边栏推荐
猜你喜欢
随机推荐
Arduino 硬件编程语言基础学习入门
默认参数的代码实现及日期的注入与显示
安装TimeGen波形绘图软件
二舅“反转”了?
数字孪生园区场景中的坐标知识
Mysql——字符串函数
一文搞懂│php 中的 DI 依赖注入
Pytest study notes
Kubernetes:(五)Pod进阶(资源限制、健康检查)
电烙铁的基础知识
关于我用iVX沉浸式体验了一把0代码项目创建
DeepMind 首席科学家 Oriol Vinyals 最新访谈:通用 AI 的未来是强交互式元学习
持续集成(五)Jenkins配置父子job
Locking and Concurrency Control (4)
Arduino hardware programming introduction to language learning
金仓数据库KingbaseES安全指南--6.11. PAM身份验证
One article to understand DI dependency injection in php
Continuous integration (4) Jenkins configuration alarm mechanism
FPGA 20个例程篇:10.遍历DDR3内存颗粒读写循环校验
golang源码分析(3):thrift









