Promise.race() - JavaScript | MDN
6
公开标注数
6
参与人数
2026-07-18 09:18:20
首次 Whisper
本页的公开 Whisper
划选高亮2026-07-18 15:42:20
原文高亮摘录
“Promise.race takes the first settled Promise.”
Whisper 随想笔记
That's the whole point, but people always confuse it with the first resolved one.
划选高亮2026-07-18 12:39:20
原文高亮摘录
“An empty iterable causes the returned promise to be forever pending”
Whisper 随想笔记
Makes sense, nothing to race means no winner, so it just waits.
划选高亮2026-07-18 12:30:20
原文高亮摘录
“An empty iterable causes the returned promise to be forever pending”
Whisper 随想笔记
So an empty array just hangs forever? That's a nasty gotcha.
划选高亮2026-07-18 09:36:20
原文高亮摘录
“Promise.race is always asynchronous: it never settles synchronously, even when the iterable is empty.”
Whisper 随想笔记
Makes sense though, keeps behavior consistent across all cases.
划选高亮2026-07-18 09:27:20
原文高亮摘录
“Promise.race is always asynchronous: it never settles synchronously, even when the iterable is empty.”
Whisper 随想笔记
Good to know, I always assumed empty meant instant reject.
划选高亮2026-07-18 09:18:20
原文高亮摘录
“Promise.race is always asynchronous: it never settles synchronously, even when the iterable is empty.”
Whisper 随想笔记
Wait, so even an empty array still waits a tick? That's wild.
分享本页 Whisper
短链接
https://domwhisper.com/s/2815785af580嵌入代码
<iframe src="https://domwhisper.com/embed/2815785af580" width="100%" height="480" style="border:0;border-radius:16px" loading="lazy"></iframe>