promise - 关于Promise,这个问题让我很困惑
问题描述
这是代码:
Promise.resolve().then(() => {
console.log(0);
return Promise.resolve(4);
}).then((res) => {
console.log(res)
})
Promise.resolve().then(() => {
console.log(1);
}).then(() => {
console.log(2);
}).then(() => {
console.log(3);
}).then(() => {
console.log(5);
}).then(() => {
console.log(6);
})
对我来说,我以为答案是 0;1;4;2;3;5;6。但结果不是。为什么?
解决方案
推荐阅读
- amazon-web-services - AWS Lambda:函数空闲
- android - 标识一个特定的动态生成的TextView,以便setText
- scala - 无法在包 org.apache.spark.ml.param.shared 中访问包 shared 中的特征 HasInputCol
- javascript - Nuxt/Vue/FE 框架性能通过 webpack 与传统 src 加载图像
- python - Django,大整数和网址
- php - 使用 3 字节搜索输入列出所有匹配的 5 字节二进制字段
- python - 有没有一种可能的方法可以用 python 合并列中重复单元格的 excel 行?
- search - 极短函数的执行时间
- powershell - 媒体协议的 PowerShell 脚本不起作用
- flutter - Flutter,Flare:在动画结束时执行函数