Promise.all为什么返回空值
时间: 2023-10-20 21:27:00 浏览: 283
Promise.all()返回空值是因为在调用Promise.all()时,传入的可迭代对象是一个空数组。根据引用中的解释,当Promise.all()接收到一个空数组时,它相当于Promise.resolve(),因此返回的是一个已解决状态的Promise,其解决值是一个空数组。所以Promise.all([])返回的是Promise {<fulfilled>: Array(0)},表示一个已解决的Promise,解决值是一个空数组。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [分享 5 个你现在就能用上的 Js ES12 新特性(数字分隔符、replaceAll()、Promise.any()、......)](https://blog.csdn.net/qq_41809113/article/details/122014755)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [JS中的异步处理方法之Promise](https://blog.csdn.net/weixin_44416058/article/details/126501653)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文