当前位置:网站首页>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);
});
边栏推荐
猜你喜欢
随机推荐
[C Language Brush Questions] Three Questions for Getting Started with Pointers | String Length, String Copy, Two Number Swap
分类实验报告作业
npm install报gyp info it worked if it ends with ok
Arduino 硬件编程语言基础学习入门
Mysql——字符串函数
创新云集技术咖,工赋汇聚实战派:2022工赋开发者峰会
golang源码分析(12)martini源码分析
Mysql开启binlog
启航
一些与开发者体验有关的话题
npm install 编译时报“Cannot read properties of null (reading ‘pickAlgorithm‘)“
MySQL常见函数
Locking and Concurrency Control (4)
golang源码分析(13)gorpc源码分析
金仓数据库KingbaseES安全指南--6.11. PAM身份验证
golang刷leetcode动态规划(8)盈利计划
牛津硕士进碳圈,高瓴红杉经纬一起投了
oracle 和mysql 语句结果不一致问题
golang源码分析(6):sync.Mutex sync.RWMutex
乌总统解除乌克兰国家安全局信息和情报分析部负责人职务