All Node.js quizzes
Intermediate30 questions40 minutes

Node.js Intermediate Quiz

Streams, error handling, async patterns and the event loop in practice — the day-to-day knowledge that separates working Node code from code that falls over under load.

Start the quiz

Sample questions from this quiz

A preview of the style and depth. Try each one, then reveal the answer — or skip straight to the timed quiz.

1. What does this print?

async function run() {
  try {
    setTimeout(() => { throw new Error('boom') }, 0)
  } catch (err) {
    console.log('caught')
  }
}
run()
console.log('after')
  • 'caught' then 'after'
  • 'after', then the process crashes on an uncaught exception
  • 'after' then 'caught'
  • 'after' only, the error is swallowed
Show answer

Answer: 'after', then the process crashes on an uncaught exception. The try/catch has already exited by the time the timer fires, so the throw happens in a fresh call stack with no handler above it. Callback errors must be handled inside the callback — try/catch cannot span an asynchronous boundary.

2. This copies a large file but uses far more memory than expected. Which line is the problem?

1  const fs = require('fs')
2  const data = fs.readFileSync('huge.bin')
3  fs.writeFileSync('copy.bin', data)
4  console.log('copied')
  • Line 2 — the entire file is buffered into memory at once
  • Line 3 — writeFileSync duplicates the buffer
  • Line 1 — fs should be imported as fs/promises
  • Line 4 — the log keeps a reference alive
Show answer

Answer: Line 2 — the entire file is buffered into memory at once. `readFileSync` holds the whole file in a Buffer, so peak memory tracks file size and the thread is blocked throughout. Piping streams — `createReadStream().pipe(createWriteStream())` — moves fixed-size chunks in roughly constant memory without blocking.

3. What does this print?

const results = []
;[1, 2, 3].forEach(async (n) => {
  results.push(await Promise.resolve(n))
})
console.log(results.length)
  • 0
  • 3
  • 1
  • undefined
Show answer

Answer: 0. `forEach` ignores the promises its async callback returns, so it finishes immediately and the log runs before any await resolves. Use `for...of` with await, or `await Promise.all(arr.map(...))` when the work can run concurrently.

Frequently asked questions

How many questions are in this Node.js quiz?+

30 questions, with a 40-minute time limit. Every question includes a written explanation of the correct answer.

Is this Node.js quiz free?+

Yes. Every quiz on CodexQuizz is free and needs no account. You only enter a name if you choose to post your score to the leaderboard.

What level is the intermediate quiz aimed at?+

Streams, error handling, async patterns and the event loop in practice — the day-to-day knowledge that separates working Node code from code that falls over under load.

Can I use this to prepare for a Node.js interview?+

Yes. The questions cover the topics that come up in Node.js technical screens, and the explanations are written so that a wrong answer still teaches you the underlying concept.

Ready to test your Node.js?

30 questions, 40 minutes. Free, no sign-up.

Start now