
A Journey Inside the Asynchronous Nature of JavaScript
When I first started writing JavaScript, Everything seemed simple and straightforward, code runs from the top to the bottom, line by line, there was no confusion, until I was introduced to Timers (setTimeout, setInterval) then some weird behavior started happening, I couldn't bring myself to understand it back then. Welcome to the asynchronous nature of JavaScript. As we were all told, JavaScript is single-threaded, That is indeed correct, JavaScript by itself cannot execute multiple operations at the same time, you can imagine a fast-food restaurant with only one cashier taking orders, this cashier can only take one order at a time, in JavaScript, This cashier is the Call Stack -The call stack is a Data Structure that executes The Last item entered the Stack (LIFO) Last In First Out- JavaScript only has one Call Stack. This means that if a function entered the Call Stack and this function took too long to execute, maybe fetching some data from an API, Will this freeze the whole applic
Continue reading on Dev.to Webdev
Opens in a new tab


