Node.js Flashcards

1
Q

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a web browser. It’s also known as what’s called a runtime environment.

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

What is a runtime environment?

A

A runtime environment is an environment in which a program or application can execute or be implemented.

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

What is a REPL and what does the acronym stand for?

A

REPL stands for read-eval-print-loop. It’s a simple interactive programming environment that takes single user inputs, executes them, and results to the user.

For example, the console in our browsers is a REPL.

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

What is blocking in JavaScript?

A

Blockingis when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes. This is what makes a language synchronous.

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

What is non-blocking?

A

Non-blocking is the opposite of blocking where multiple operations can be performed at the same time. This is what makes a language asynchronous.

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

What is the difference between a library and framework?

A

Libraries consist of functions that an application can call to perform a task while a framework defines how a developer designs an application.

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

What is a computer process?

A

A computer process refers to a set of instructions currently being processed by the computer processor.

For example, if you look at your control panel or activity monitor, you’ll see that you have a lot of processes going on.

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

What is the process object?

A

The process object is a global that provides info about, and control over, the current Node.js process. It’s always available to Node.js applications without using require( ).

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

How do you access the process object in a Node.js program?

A

By calling the require function with ‘process’ as its argument.

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

What does process.argv return?

A

Returns an array of arguments starting at the index 2. Index 1 is the file path of the executable that started the Node process while index 2 is the file path to the JavaScript file being executed.

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

What is modular programming?

A

Separating behavior into multiple standalone functions.

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

What is a module in Node.js?

A

A module is a single JS file.

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

What does the require( ) function do?

A

The built-in function is the easiest way to include modules that exist in separate files. It reads a JavaScript file, executes the file, and then process to return the exports object.

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

What does Node.js do specifically before a module’s mode is executed when loading modules?

A

Before a module’s code is executed, Node.js will wrap it with a function wrapper with the module code living in the code block of the function wrapper.

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

What are the five parameters in a function wrapper before loading another module?

A

exports, require, module, __filename, __dirname

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

When loading a module, are variables in the module code local or global?

A

Local because the module is wrapped in a function by Node.js

17
Q

What module does Node.js include for manipulating the file system?

A

fs module

18
Q

What is “utf8” and why do you need it in the readFile method?

A

Utf-8 is an encoding system that translates characters to matching binary strings. You need it in the method because the readFile method reads the file in binary so we need to encode it using utf-8.