Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What is the role of the call stack in the JavaScript runtime?

View

What happens when an asynchronous operation like setTimeout() is encountered in JavaScript?

View

Which of the following statements about the event loop is true?

View

How does the event loop handle promises?

View

What is the main difference between the task queue and the microtask queue in the event loop?

View

When is a setTimeout() callback executed in the event loop?

View

What is the purpose of process.nextTick() in Node.js?

View

What is the behavior of Promise.resolve().then() in the event loop?

View

How does JavaScript handle multiple setTimeout() callbacks with the same delay?

View

Which of the following will execute first in the event loop?

View

What is the role of the call stack in the JavaScript runtime?

To manage the execution of function calls.
To store asynchronous operations.
To manage event listeners.
To handle memory allocation.

What happens when an asynchronous operation like setTimeout() is encountered in JavaScript?

It is placed in the task queue to be executed after the call stack is clear.
It is immediately executed.
It is placed in the call stack.
It pauses all other operations.

Which of the following statements about the event loop is true?

It continuously checks if the call stack is empty and processes the task queue if it is.
It only processes synchronous tasks.
It is responsible for garbage collection.
It ensures that synchronous tasks are delayed for asynchronous tasks.

How does the event loop handle promises?

It places resolved promises in the task queue.
It places resolved promises in the microtask queue, which is processed before the task queue.
It executes promises synchronously.
It waits for all promises to resolve before proceeding with other tasks.

What is the main difference between the task queue and the microtask queue in the event loop?

The task queue is processed before the microtask queue.
The task queue is for synchronous code, while the microtask queue is for asynchronous code.
There is no difference; both queues are processed simultaneously.
The microtask queue has higher priority and is processed after each task, while the task queue processes tasks like setTimeout.

When is a setTimeout() callback executed in the event loop?

After the call stack is clear and the microtask queue is empty.
Immediately after the specified time.
Before the call stack is cleared.
After all other synchronous tasks, even if the time hasn't passed.

What is the purpose of process.nextTick() in Node.js?

It schedules a callback to be invoked in the next iteration of the event loop, before any I/O tasks or timers.
It adds a callback to the task queue.
It pauses the execution of the event loop.
It immediately clears the call stack.

What is the behavior of Promise.resolve().then() in the event loop?

It adds the callback to the task queue.
It adds the callback to the microtask queue, which is processed before any task queue items.
It immediately executes the callback.
It pauses the execution of the event loop.

How does JavaScript handle multiple setTimeout() callbacks with the same delay?

They are executed simultaneously.
They are added to the microtask queue and executed before other tasks.
They are added to the task queue in the order they are defined and executed sequentially.
Only the last callback will be executed.

Which of the following will execute first in the event loop?

A microtask, such as a resolved promise.
A setTimeout() callback with a delay of 0 milliseconds.
A console.log() inside an async function.
An asynchronous I/O operation.