Skip to content
Y
yTube.SITE v8.0.4
media / worlds / tools / internet oddities
YouTube / video information

Promise Callbacks Are Microtasks

Video information, playback and saved actions.

Promise Callbacks Are Microtasks

Description: Why does `Promise.resolve().then(...)` run before `setTimeout(..., 0)`, even when the timer was scheduled first?

Promise `.then()` callbacks run as microtasks. After the current JavaScript task finishes, the event loop runs all queued microtasks before starting the next task, such as a setTimeout callback. Close description
      
Videos related to "Promise Callbacks Are Microtasks"