JSNAD Flashcards
(14 cards)
What is the purpose of the nvm tool in Node.js?
It manages multiple versions of Node.js on a system.
CLI flags: What does -p do in Node.js CLI?
Prints the result of the expression.
What does –stack-trace-limit control?
The depth of stack traces for debugging errors.
Difference between CommonJS and ES Modules?
CommonJS uses require(), ES Modules use import/export.
What’s the role of the Event Loop in Node.js?
It handles asynchronous operations and callbacks.
What is EventEmitter used for?
Managing custom events in an event-driven architecture.
When would you use a Stream in Node.js?
For reading or writing large data chunks efficiently (e.g., file I/O, network).
Buffer vs. Stream?
Buffers store binary data in memory; Streams process data in chunks.
How do you handle files in Node.js?
Use fs module – it has both synchronous and asynchronous methods.
Purpose of process and os modules?
To access environment variables, system info, and manage processes.
What is a Child Process in Node.js?
A subprocess created using the child_process module for parallel tasks.
What should a robust error-handling approach include?
Try/catch blocks, error callbacks, and process.on(‘error’) handlers.
What frameworks are common for unit testing in Node.js?
Mocha, Jest, and Node’s built-in assert module.
What’s the benefit of using Promises or async/await over callbacks?
They make asynchronous code more readable and easier to maintain.