Node.js Flashcards

1
Q

What is Node.js?

A

An asynchronous event-driven JavaScript runtime, Node.js is a program that allows JavaScript to be run outside of a web browser.

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

Build back ends for Web applications, command-line programs, or any kind of automation

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 (REPL) reads input from the user, executes them, and returns the result to the user.

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

When was Node.js created?

A

2009

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

What back end languages have you heard of?

A

PHP, Ruby on Rails, C#, Java

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

What is a computer process?

A

The execution of code/program/application by one or more threads

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

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

A

hundreds

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

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

A

Full stack is made up of many modules. To track the status of the server, check its pid.

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

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

A

Global variable with information about and control over the current Node.js process.

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

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

A

process variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
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
12
Q

What is a JavaScript module?

A

JavaScript file

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

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

A

dirname, filename, exports, required

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

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

A

process, argv, console

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

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

A

Allows you to write modular code and easily reuse it by importing and exporting.

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

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

A

Use require.

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

What is a directory?

A

A node in the file system that contains other files and directories.

18
Q

What is a relative file path?

A

A path with . or .. to indicate current dir and parent dir respectively.

19
Q

What is an absolute file path?

A

A path with the all parent dirs from the root down.

20
Q

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

21
Q

How do you add express to your package dependencies?

A

npm install

22
Q

What Express application method starts the server and binds it to a network PORT?

23
Q

How do you mount a middleware with an Express application?

A

Use a middleware method: use(), get(), post(), put(), delete()

24
Q

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

req, res, and next

25
What is NPM?
the website, command line interface, and registry
26
What is a package?
Module that has been added to npm's registry
27
How can you create a package.json with npm?
npm init
28
What is a dependency and how to you add one to a package?
A package the module uses or needs. npm install
29
What happens when you add a dependency to a package with npm?
Adds dependency to node module dir. Adds it to package.json.
30
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json; charset=utf-8
31
What does the express.json() middleware do and when would you need it?
Parses http request body from JSON to an object. Needed when you expect a JSON string in a http post request
32
What is Webpack?
Webpack bundles together JS modules into one file to prevent a network bottleneck that could occur when loading multiple files. Webpack uses Immediately invoked function expressions (IIFE) to concatenate files without scope collision.
33
How do you add a devDependency to a package?
Install dependency and check that it shows up in package.json under dependencies.
34
What is an NPM script?
NPM supports a number of built-in scripts. To use, list them in your package.json under scripts and call NPM build on them.
35
How do you execute Webpack with npm run?
Insert a "build" property under scripts in package.json. Run "npm run build".
36
What does express.static() return?
Middleware function that serves static files
37
What is the local __dirname variable in a Node.js module?
Path of the current JavaScript file's directory.
38
What does the join() method of Node's path module do?
Concatenates the two args, which should represent paths and directory names
39
What does fetch() return?
a promise
40
What is the default request method used by fetch()?
GET
41
How do you specify the request method (GET, POST, etc.) when calling fetch?
{ method: }