Flashcards

Asynchronous

1. What are the arguments that the setTimeout and setInterval methods can accept?

2. What does the setTimeout method return in the Node environment?

3. What does the setTimeout method return in the browser environment?

4. Is JavaScript single-threaded or multi-threaded?

5. What is the difference between single-threaded and multi-threaded execution?

6. What are the two main data structures that comprise JavaScript’s event loop?

7. When a function is called, what occurs on the call stack?

8. When a function returns, what occurs on the call stack?

9. In the JavaScript event loop, what is the message queue used for?

10. When an event triggers, what occurs in the JavaScript runtime’s message queue?

11. In what order will the following code print to the console?

console.log("first");

setTimeout(function () {
  console.log("second");
}, 0);

console.log("third");

12. What must occur for items to be dequeued (removed) from the JavaScript runtime’s message queue?

13. What is the difference between synchronous and asynchronous code?