- Memory Heap: this is where the memory allocation happens
- Call Stack: this is where your stack frames are as your code executes
Within JS , we have WebAPIs ,Callback queue, and Event Loops that is used to run the JS code that is responsible for to achieve Async.
- Web API: this executes the timeout function and places the code in the callback queue
- Call Back Queue: these are queues that hold callback functions to asynchronous operations when they have been completed in the background.
- Eventloop: this checks if the call stack is empty or not or whether there is any statement in the callback queue that needs to be executed all the time
Try this below sample code