Call Stack Event Loop Flashcards
What is a potential downside of a very long-running function in JavaScript’s single-threaded environment?
The browser becomes unresponsive until the function execution completes.
Which of the following best describes the “event loop” in JavaScript?
A loop in the JS runtime that checks the Call Stack and Callback Queue.
Why is it advisable not to perform heavy computations synchronously in JavaScript?
It can block the call stack, making the UI unresponsive.
What does the call stack do when it encounters an asynchronous function like setTimeout?
Pushes the function to the Web API and continues executing subsequent synchronous tasks.
What is the maximum call stack size in JavaScript?
It is determined by the available system memory.
What component of the JavaScript runtime environment is responsible for task management and scheduling?
Event Loop
What type of errors can break the event loop?
Runtime errors.
Which of the following execute in the Web API environment? Select all that apply.
DOM events
AJAX calls
setTimeout
What happens when there is a stack overflow in JavaScript?
A RangeError is thrown.
How does the Event Loop decide what to execute next?
Checks the Call Stack, and if it is empty, takes tasks from the Callback Queue.
What is the primary role of the JavaScript call stack?
To store the context of function calls.