Skip to content

Nodejs Runtime

Master Nodejs Runtime with 50 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.

🎓 50 cards ⏱️ ~25 min Advanced
Study Full Deck →
Share: 𝕏 Twitter LinkedIn WhatsApp

🎯 What You'll Learn

Preview Questions

12 shown

What is Node.js?

Show ▼

Node.js is a JavaScript runtime built on Chrome's V8 engine. It allows running JavaScript outside the browser, using an event-driven, non-blocking I/O model that makes it lightweight and efficient for building scalable network applications.

What is the Node.js event loop?

Show ▼

The event loop is the mechanism that allows Node.js to perform non-blocking I/O operations despite JavaScript being single-threaded. It continuously checks the call stack and callback queue, executing callbacks when the stack is empty. Phases include: timers → pending callbacks → idle/prepare → poll → check → close callbacks.

What are the phases of the Node.js event loop?

Show ▼

Timers – executes setTimeout and setInterval callbacksPending callbacks – I/O callbacks deferred to next iterationPoll – retrieves new I/O eventsCheck – executes setImmediate callbacksClose callbacks – e.g. socket.on('close')

What is the difference between setImmediate() and setTimeout()?

Show ▼

setImmediate() executes in the check phase of the event loop, after the poll phase completes. setTimeout(fn, 0) executes in the timers phase on the next iteration. When called within an I/O callback, setImmediate() always fires before setTimeout().

What is process.nextTick() and how does it differ from setImmediate()?

Show ▼

process.nextTick() fires immediately after the current operation, before the event loop continues. It is processed on the microtask queue, not part of any event loop phase. setImmediate() fires on the next iteration of the event loop. Overusing nextTick can starve I/O.

What are Streams in Node.js?

Show ▼

Streams are objects that let you read or write data continuously in chunks rather than loading everything into memory. There are four types:Readable – e.g. fs.createReadStream()Writable – e.g. fs.createWriteStream()Duplex – both readable and writable (e.g. TCP socket)Transform – modifies data as it passes through (e.g. zlib.createGzip())

How do you pipe streams in Node.js?

Show ▼

Use the .pipe() method to connect a readable stream to a writable stream:
const fs = require('fs');
fs.createReadStream('input.txt')
  .pipe(fs.createWriteStream('output.txt'));

The modern alternative is pipeline() from stream/promises, which handles errors automatically.

What is backpressure in Node.js streams?

Show ▼

Backpressure occurs when a writable stream cannot consume data as fast as a readable stream produces it. Node.js handles this by returning false from writable.write(), signaling the readable stream to pause. The 'drain' event on the writable stream indicates it's ready for more data.

What is the CommonJS module system?

Show ▼

CommonJS is Node.js's original module system. Modules are loaded synchronously using require() and exported using module.exports or exports:
const fs = require('fs');
module.exports = { myFunc };

Each file is treated as a separate module with its own scope.

What is the ES Modules (ESM) system in Node.js?

Show ▼

ESM is the official JavaScript module standard, supported in Node.js 12+. Uses import/export syntax:
import fs from 'fs';
export function myFunc() {}

Enable via "type": "module" in package.json or use .mjs file extension. ESM is asynchronous and supports top-level await.

What are the key differences between CommonJS and ESM?

Show ▼

Loading: CommonJS is synchronous; ESM is asynchronousSyntax: require/module.exports vs import/exportScope: CommonJS wraps in a function; ESM has strict mode by defaultTop-level await: Only ESM supports itCaching: Both cache modules, but ESM uses live bindings

What is Express.js middleware?

Show ▼

Middleware functions are functions that have access to the request object (req), response object (res), and the next function (next). They can:Execute codeModify req and resEnd the request-response cycleCall next() to pass control to the next middleware

🎓 Start studying Nodejs Runtime

🎮 Study Modes Available

🔄

Flashcards

Flip to reveal

🧠

Focus Mode

Spaced repetition

Multiple Choice

Test your knowledge

⌨️

Type Answer

Active recall

📚

Learn Mode

Multi-round mastery

🎯

Match Game

Memory challenge

Related Topics in Programming

📖 Learning Resources