Apsar Ali’s Post

Day 13/100 of JavaScript Missed a day, but continuing the streak Today’s topic: Call Stack and Event Loop JavaScript is single-threaded, which means it executes one task at a time using a call stack - Call Stack → manages function execution (LIFO) - Functions are pushed when called and popped after execution For asynchronous operations, JavaScript uses: - Web APIs - Callback Queue / Microtask Queue - Event Loop Example: console.log("Start"); setTimeout(() => { console.log("Timeout"); }, 0); console.log("End"); Output: Start End Timeout Even with 0 delay, "setTimeout" executes later because it goes through the event loop The event loop ensures asynchronous tasks are executed only when the call stack is empty No matter the delay, consistency continues #Day13 #JavaScript #100DaysOfCode

To view or add a comment, sign in

Explore content categories