JavaScript Runtime Flashcards
What is the runtime in the browser?
Essentially a container which includes all the pieces necessary to execute javascript code
What is the engine?
The “heart” of the runtime, where code is actually executed and where objects are stored in memory
Where is code executed at runtime
On the call stack
Where are objects stored in memory?
On the heap
How many threads of execution does JavaScript use?
One
What are the DOM, Fetch API and Timers a collection of?
Web APIs provided to the engine, they are not part of javascript
What is the callback queue?
A data structure that holds the callback functions ready to be executed coming from events e.g. clicks, timers, data (fetch(), setTimeout() etc)
What does the event loop do?
Takes callbacks from the callback queue / microtasks queue and adds them to the call stack
Why is the event loop so important
It allows us to perform asynchronous javascript tasks
Where to image request happen at runtime?
In the Web API environment - if they were to run on the call stack they’d block it
Where does an event listener wait once its been registered by the runtime and where does it go to once it’s been called?
It waits in the web API and mo ves to the callback queue once called e.g. a click happens