Skip to content

Latest commit

 

History

History
14 lines (7 loc) · 556 Bytes

what_is_the_purpose_of_queuemicrotask.md

File metadata and controls

14 lines (7 loc) · 556 Bytes

What is the purpose of queueMicrotask?

The queueMicrotask() method is used to add a microtask to the event loop queue. It is similar to using a promise but ensures that the task will be executed as soon as the current task completes, before any rendering or other tasks.

Example:

queueMicrotask(() => console.log('Microtask executed'));

**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Event Loop](./theme/event_loop)