Node.js / NPM Flashcards

1
Q

What is Node.js?

A

Node.js is a JavaScript runtime environment that executes JS code outside web browsers.

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

What can Node.js be used for?

A

Node.js is used for backend operations in JavaScript.

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

What is a REPL?

A

A Read-Eval-Print-Loop is a command-line tool for processing expressions.

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

What is a computer process?

A

An instance of a computer program being executed by one or many threads.

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

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

At least 200.

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

Why should a full stack Web developer know that computer processes exist?

A

It is an important concept in apps made up of multiple components such as clients, servers, and databases.

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

What is the process object in a Node.js program?

A

An object that represents the current instance of the node process being run.

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

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

A

process exists as a global variable.

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

What is the data type of process.argv in Node.js?

A

Array of strings.

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

What is a JavaScript module?

A

single .js file with a standalone function.

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

What values are passed into a Node.js module’s local scope?

A

exports, require, module, __filename, __dirname

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

Give two examples of truly global variables in a Node.js program.

A

process, global

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

What is the purpose of module.exports in a Node.js module?

A

module.exports contains data that can be imported into other modules.

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

How do you import functionality into a Node.js module from another Node.js module?

A

const func = require(‘./func’);

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

What is the JavaScript Event Loop?

A

A design pattern that loops through the call stack and the callback queue, checking if the stack is empty and pushing functions onto it from the queue if it is.

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

What is different between “blocking” and “non-blocking” with respect to how code is executed?

A

Blocking calls block further execution of functions in the stack until they return whereas non-blocking calls do not.

17
Q

What is NPM?

A

Node Package Manager, made up of a website, a command-line interface, and a registry of software packages. The CLI installs and updates packages.

18
Q

What is a package?

A

One or more modules grouped together.

19
Q

How can you create a package.json with npm?

A

Navigate to root directory of package and execute “npm init [–yes]”.

20
Q

What is a dependency and how do you add one to a package?

A

A dependency is a package needed to run another package. They are added by the command “npm install package-name [–save-prod]”.

21
Q

What happens when you add a dependency to a package with npm?

A

When another user runs “npm install”, npm will install the dependencies listed in package.json.

22
Q

What is a directory?

A

A file system cataloguing structure that contains references to other computer files and directories.

23
Q

What is a relative file path?

A

A file path relative to the current directory.

24
Q

What is an absolute file path?

A

A file path beginning from the root.

25
Q

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

A

The fs module.

26
Q

What method is available in the Node.js fs module for writing data to a file?

A

.writeFile()

27
Q

Are file operations using the fs module synchronous or asynchronous?

A

fs has both synchronous and asynchronous versions of operations.