当前位置:网站首页>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);
});
边栏推荐
猜你喜欢
随机推荐
「全球数字经济大会」登陆 N 世界,融云提供通信云服务支持
oracle 和mysql 语句结果不一致问题
使用lodash替换js字符串中的变量
Switch 块、Switch 表达式、Switch 模式匹配,越来越好用的 Switch
golang源码阅读(11)GO中各个目录的功能
npm install 报错问题解决合集
MYSQL一站式学习,看完即学完
golang源码分析(4):select
Timestamp formatting "recommended collection"
一些与开发者体验有关的话题
Kubernetes:(五)Pod进阶(资源限制、健康检查)
如何生成随机数+原理详细分析
Pytest study notes
npm install报gyp info it worked if it ends with ok
内网渗透之kerberos认证(三)
npm install 时,卡住不动,五种解决方法
Red and blue against experience sharing: CS from kill posture
【genius_platform软件平台开发】第七十五讲:YUY2转RGB24实现源码
js实现改变原来对象中的键值对对应的值
Detailed explanation of the principle of JWT_The principle of electromagnetic induction









