Promise2 [Javascript] Promise.allSettled vs Promise.all, Promise states Pending Fulfilled Rejected Promise.all vs Promise.allSettled all // All values are non-promises, so the returned promise gets fulfilled const p = Promise.all([1, 2, 3]); // The only input promise is already fulfilled, // so the returned promise gets fulfilled const p2 = Promise.all([1, 2, 3, Promise.resolve(444)]); // One (and the only) input promise is rejected, // so the returned promis.. 2023. 1. 7. [javascript] Promise vs setTimeout:: why Promise resolved first? Why Promise is resolved before setTimeout? - Event loop, task queue, micro task queue, stack Promise vs setTimeout Promise.resolve schedules a microtask and the setTimeout schedules a macrotask. And the microtasks are executed before running the next macrotask. console.log(1) setTimeout(() => { console.log(3) }); Promise.resolve().then(() => console.log(4)) console.log(7) Interesting question. I.. 2023. 1. 7. 이전 1 다음