
Node.js Fundamentals
Event loop, non-blocking I/O, CommonJS/ES6 modules, package.json, npm/yarn
1What is the event loop in Node.js?
What is the event loop in Node.js?
답변
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.
2What is the main characteristic of Node.js I/O model?
What is the main characteristic of Node.js I/O model?
답변
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.
3What is the main difference between require() and import?
What is the main difference between require() and import?
답변
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.
What is the purpose of package.json file?
What is the role of the node_modules folder?
+17 면접 질문