Back

Suyash Patil

Frontend Engineer • 3m

One interesting thing to look into when it comes to the 𝗲𝘃𝗲𝗻𝘁 𝗹𝗼𝗼𝗽 is how JavaScript handles macrotasks and microtasks. 𝗠𝗮𝗰𝗿𝗼𝘁𝗮𝘀𝗸𝘀: Macrotasks are typically large, high-level operations like setTimeout, setInterval, and user interactions (e.g., click, scroll). 𝗠𝗶𝗰𝗿𝗼𝘁𝗮𝘀𝗸𝘀: Microtasks, often created by Promises or queueMicrotask, are lightweight tasks that are always processed after the current execution context but before any rendering or macrotasks. Microtasks are executed immediately after the current script and before any rendering, making them a reliable way to ensure certain tasks (like promises) are handled promptly. Macrotasks are handled in a “first come, first served” manner, which includes things like timers and I/O events.

Reply
1
11

More like this

Recommendations from Medial

Image Description
Image Description

Suman Meghwal

Wealthseeker • 5m

Ravi, 32, was seated at his desk, feeling pressured by a challenging deadline. As the stress increased, he sensed his anxiety grow, thinking, “I won’t be able to complete it on time.” His thoughts sped with negativity, rendering the task seem unachie

See More
9 Replies
2

Download the medial app to read full posts, comements and news.