JS Runtime Flashcards

(19 cards)

1
Q

What is the event Loop in JavaScript?

A

A tiny component within the JavaScript runtime that manages asynchronous tasks.

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

What does the Call Stack do in JavaScript?

A

Manages the execution of the program by handling function calls and execution contexts.

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

True or False: JavaScript is multi-threaded.

A

False

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

What happens when a long-running task is executed in JavaScript?

A

The entire program is frozen until the task is completed.

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

What are Web APIs in JavaScript?

A

Interfaces that allow interaction with the browser’s features like DOM, fetch, and timers.

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

Fill in the blank: The browser handles long-running tasks through _______.

A

Web APIs

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

What are Callback-based APIs?

A

APIs that use callbacks to handle asynchronous operations.

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

What is the Task Queue?

A

Also called the Callback queue, it holds web API callbacks and event handlers to be executed later.

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

What is the role of the Event Loop?

A

Checks if the call stack is empty and moves tasks from the task queue to the call stack for execution.

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

What does setTimeout do?

A

Registers a callback to be executed after a specified delay.

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

Fill in the blank: The delay specified in setTimeout is the delay until it gets moved to the _______.

A

Task Queue

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

What is the Microtask Queue?

A

A special queue for promise callbacks, async function bodies after await, and mutation observer callbacks.

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

True or False: The Microtask Queue has lower priority than the Task Queue.

A

False

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

What happens when a promise resolves?

A

A promise reaction is created and pushed to the Microtask Queue.

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

What is a potential issue with Microtasks?

A

A microtask can schedule another microtask, potentially creating an infinite loop.

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

What is Promisifying Callbacks?

A

Wrapping callback-based APIs in a Promise constructor for better readability.

17
Q

Recap: What is the main purpose of Web APIs in JavaScript?

A

To initiate asynchronous tasks in the background without blocking the call stack.

18
Q

What does the Event Loop ensure after handling each task from the Task Queue?

A

It checks the Microtask Queue to ensure it’s empty before moving on.

19
Q

What can help improve understanding of asynchronous JavaScript execution?

A

Playing around with setTimeout and Microtasks.