Call Stack Event Loop Flashcards

1
Q

What is a potential downside of a very long-running function in JavaScript’s single-threaded environment?

A

The browser becomes unresponsive until the function execution completes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following best describes the “event loop” in JavaScript?

A

A loop in the JS runtime that checks the Call Stack and Callback Queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why is it advisable not to perform heavy computations synchronously in JavaScript?

A

It can block the call stack, making the UI unresponsive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the call stack do when it encounters an asynchronous function like setTimeout?

A

Pushes the function to the Web API and continues executing subsequent synchronous tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the maximum call stack size in JavaScript?

A

It is determined by the available system memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What component of the JavaScript runtime environment is responsible for task management and scheduling?

A

Event Loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What type of errors can break the event loop?

A

Runtime errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the following execute in the Web API environment? Select all that apply.

A

DOM events
AJAX calls
setTimeout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens when there is a stack overflow in JavaScript?

A

A RangeError is thrown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does the Event Loop decide what to execute next?

A

Checks the Call Stack, and if it is empty, takes tasks from the Callback Queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the primary role of the JavaScript call stack?

A

To store the context of function calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly