Web APIs

queueMicrotask()

Try the free JavaScript compiler

Queues a callback as a microtask. A browser checkpoint processes queued microtasks, including new additions. Errors thrown by the callback are reported through the host’s error mechanism.

Formal Syntax & Structure

javascript syntaxjavascript
queueMicrotask(callback)

Parameters & Attributes

NameTypeDescription
callbackfunctionCallback to run at a microtask checkpoint.

Return Value

undefined

No return value.

Working Example

Example Snippetjavascript
queueMicrotask(() => { console.log("A"); queueMicrotask(() => console.log("C")); });Promise.resolve().then(() => console.log("B"));console.log("S");
JavaScript Reference