JSNAD Flashcards

(14 cards)

1
Q

What is the purpose of the nvm tool in Node.js?

A

It manages multiple versions of Node.js on a system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

CLI flags: What does -p do in Node.js CLI?

A

Prints the result of the expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does –stack-trace-limit control?

A

The depth of stack traces for debugging errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Difference between CommonJS and ES Modules?

A

CommonJS uses require(), ES Modules use import/export.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What’s the role of the Event Loop in Node.js?

A

It handles asynchronous operations and callbacks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is EventEmitter used for?

A

Managing custom events in an event-driven architecture.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When would you use a Stream in Node.js?

A

For reading or writing large data chunks efficiently (e.g., file I/O, network).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Buffer vs. Stream?

A

Buffers store binary data in memory; Streams process data in chunks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you handle files in Node.js?

A

Use fs module – it has both synchronous and asynchronous methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Purpose of process and os modules?

A

To access environment variables, system info, and manage processes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a Child Process in Node.js?

A

A subprocess created using the child_process module for parallel tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What should a robust error-handling approach include?

A

Try/catch blocks, error callbacks, and process.on(‘error’) handlers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What frameworks are common for unit testing in Node.js?

A

Mocha, Jest, and Node’s built-in assert module.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s the benefit of using Promises or async/await over callbacks?

A

They make asynchronous code more readable and easier to maintain.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly