Interview Q&A / Node.js

INTERVIEW Q&A · 68 QUESTIONS

Node.js interview questions

The event loop on the server, streams, modules and building APIs with Express.

  1. What are streams in Node.js and why would you use them for large files?

    A stream processes data in small chunks as it arrives instead of loading everything into memory at once. For a large file, streams keep memory use low and let you start sending data immediately, and pipeline() handles backpressure and errors for you.

    IntermediateIn-depth3 min read
  2. Should you use await inside a for loop or Promise.all for independent tasks?

    For independent tasks use Promise.all with map so they run concurrently. await inside a loop runs them one by one, which is right only when each step depends on the last or order and rate limits matter.

    IntermediateQuick answer1 min read
  3. What is backpressure in Node.js streams?

    Backpressure is when a writable cannot consume data as fast as a readable produces it. The writable signals this, and the reader should pause, otherwise memory fills up with unwritten data.

    IntermediateQuick answer1 min read