Node.js / NestJS

Node.js Fundamentals

Event loop, non-blocking I/O, CommonJS/ES6 modules, package.json, npm/yarn

20 interview questionsยท
Junior
1

What is the event loop in Node.js?

Answer

The event loop is the central mechanism in Node.js that enables asynchronous execution. It monitors the call stack and callback queue, executing callbacks when the call stack is empty. This mechanism allows Node.js to handle thousands of simultaneous connections without creating additional threads, making the model very efficient for I/O operations.

2

What is the main characteristic of Node.js I/O model?

Answer

Node.js uses a non-blocking, asynchronous I/O model. When an I/O operation is initiated (file read, network request), Node.js doesn't wait for its completion and continues executing other tasks. Once the operation completes, a callback is added to the queue. This model enables excellent performance for applications with many concurrent I/O operations.

3

What is the main difference between require() and import?

Answer

require() is CommonJS syntax, loaded synchronously at runtime. import is ES6 modules syntax, statically analyzed before execution. ES6 modules enable tree-shaking (dead code elimination) and offer better optimization. CommonJS remains widely used for compatibility, while ES6 modules is becoming the modern standard.

4

What is the purpose of package.json file?

5

What is the role of the node_modules folder?

+17 interview questions

Master Node.js / NestJS for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free