Node.js / NestJS

Node.js Fundamentals

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

20 câu hỏi phỏng vấn·
Junior
1

What is the event loop in Node.js?

Câu trả lời

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?

Câu trả lời

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?

Câu trả lời

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 câu hỏi phỏng vấn

Nắm vững Node.js / NestJS cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí