Web APIs
queueMicrotask()
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
| Name | Type | Description |
|---|---|---|
| callback | function | Callback 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");