promise的用法,为什么不是运行出3呢?ex是什么意思?

news/2024/7/19 16:20:57 标签: js
const promise = new Promise(function(resolve, reject) {
    setTimeout(function() {
        try{
            let c = 6 / 2 ;
            resolve(c);
        } catch(ex) {
            reject(ex);
        }
    }, 1000)
})

不知道怎么debug得出3来。

为啥是underfined?

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
	</head>
	<body>
		
	
	    
		<script>
		 const promise = new Promise(function(resolve, reject) {
			 setTimeout(function() {
				 try{
					 let c = 6 / 2 ;
					 resolve(c);
					 console.log(resolve(c))
				 } catch(ex) {
					 reject(ex);
				 }
			 }, 2000)
		 })
		</script>
	</body>
</html>


http://www.niftyadmin.cn/n/957354.html

相关文章

ray安装踩坑记录

Ray是个复杂的库&#xff0c;安装非常依赖各个包的版本&#xff0c;只要按照时间顺序&#xff0c;逐个安装即可。 坑一&#xff1a; 当前ray的最新版本为1.8.0&#xff0c;对应的cloudpickle为2.0.0&#xff0c;无法执行 ray.init() 报错为typeerror&#xff1a;cant pickl…

【Pytorch异常笔记】Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.

异常描述 OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized. OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or c…

zip函数和zip(*)函数

zip() 函数用于将可迭代的对象作为参数&#xff0c;将对象中对应的元素打包成一个个元组&#xff0c;然后返回由这些元组组成的列表。 如果各个迭代器的元素个数不一致&#xff0c;则返回列表长度与最短的对象相同。 zip(*)函数利用 * 号操作符&#xff0c;可以将元组解压为列…

pytorch ray 出现 Windows fatal exception: access violation错误的解决方案(远程主机强迫关闭了一个现有的连接)

训练PPO算法&#xff0c;出现Windows fatal exception: access violation问题。PPO算法是一个多线程算法&#xff0c;为了加速训练&#xff0c;使用GPU和显存加速计算。该问题不能稳定复现。 为了节约现存&#xff0c;PPO的公共参数 储存在内存中&#xff0c;worker数据存储在…

RuntimeError: CUDA error: an illegal instruction was encountered

不是一个能稳定复现的bug&#xff0c;很有可能是显卡坏了&#xff0c;除了换显卡&#xff0c;没有找到解决方法。

用yarn 运行vue项目的命令是

两个 一个yarn 作用是安装yarn 第二个是yarn dev 就可以了 第二个不是yarn serve

域名添加cdn_快速获取域名解析(子域名)和CDN背后的真实IP(非爆破)

“你的眼睛很美&#xff01;犹如我的眼睛里有星空、有未来、还有你。”——选自文集《我在人间凑数的日子》本期先讲讲CND背后的真实IP和子域名的获取下期如果防止CDN背后真实IP如何防止泄露DNS1.大部分CDN接入都会以NS方式接入&#xff0c;可以以 CNAME 方式接入&#xff0c;区…

keydown,keyup的用法

<!DOCTYPE html> <html> <head> <meta charset"utf-8"> <title>菜鸟教程(runoob.com)</title> <script src"https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(do…