epam-short-track

Async JavaScript cross interview #5

Async JavaScript:

  1. What is the purpose of timers in JavaScript, and how do they work?
  2. Explain the difference between setTimeout() and setInterval().
  3. How can you stop the execution of a function set with setInterval() in JavaScript?
  4. How can you pass a value to the parameter of a callback function in setTimeout?
  5. What is a Promise in JavaScript, and how does it handle asynchronous operations?
  6. What are the possible states of a Promise, and what does each state signify?
  7. What static methods of Promises are you familiar with in JavaScript?
  8. How do Promise.all() and Promise.race() differ in their usage?
  9. Provide an example of chaining multiple promises together.
  10. What is the significance of handling errors at different points in the chain?
  11. How can you handle errors in a promise chain?
  12. Explain how async and await enhance the readability of asynchronous code.

JavaScript Errors:

  1. What is the purpose of the try..catch statement in JavaScript?
  2. How does error propagation work in a synchronous JavaScript function?
  3. Explain the differences between a SyntaxError and a TypeError in JavaScript.
  4. How can you create and throw a custom error in JavaScript?
  5. What is the significance of the finally block in error handling?
  6. Provide an example where throw is used within a function.
  7. How can custom errors be used to enhance debugging and error handling?
  8. When would capturing stack traces be beneficial in error management?
  9. Describe how unhandled errors in Promises are different from those in synchronous code.
  10. How can the Error constructor be used to enhance thrown exceptions?

Event loop (V8 & NodeJS):

  1. What is the event loop in JavaScript, and why is it crucial?
  2. Describe the difference in event loop mechanisms between browsers (like Chrome’s V8 engine) and Node.js.
  3. How do microtasks and macrotasks impact the execution of JavaScript code?
  4. How does the call stack interact with the event loop in handling function execution?
  5. What role do Web APIs play in the event loop process within browser environments?
  6. What happens in the event loop when a JavaScript execution stack is full?
  7. How does the event loop handle high-priority tasks such as user input or animations?
  8. How does the event loop prioritize different types of callbacks, such as those from setTimeout, setImmediate, and I/O operations?