Node.js Flashcards

1
Q

What is Node.js?

A

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

To build back ends for web applications, command-line programs or any kind of automations that devs wish to perform.

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

What is a REPL?

A

Read-eval-print loop. It is a simple interactive computer programming environment that takes single user inputs, 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

It was created May 27, 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

JavaScript, Java, Python, Ruby, PHP, VBA

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

What is a computer process?

A

The instance of a computer program that is being executed by one or many threads (smallest sequence of programmed instructions). It contains the program code and its activity.

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

6

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

Based on multiple processes to make applications work. Programming server and database.

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

A global that provides 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

You can just call the ‘process’ object since it is a global variable or by using require(‘process’).

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

An 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

It is a 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

File name, dir name, exports, module, require

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 and 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

To be able to access it from another file

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

Using ‘require’ function using the relative file path

17
Q

What is a directory?

A

A file containing the list of files and/or directories

18
Q

What is a relative file path?

A

Starts with “./” (sibling directory) or “../” (parent directory)

19
Q

What is an absolute file path?

A

The full file path from the root directory.

20
Q

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

21
Q

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

A

fs.writeFile

22
Q

Are file operations using the fs module synchronous or asynchronous?

A

Both synchronous and asynchronous, depending on the method

23
Q

How do you add express to your package dependencies?

A

Install npm express

24
Q

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

25
How do you mount a middleware with an Express application?
‘Use’ method of the app object.
26
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
Request and response
27
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
28
What does the express.json() middleware do and when would you need it?
The express.json parses the incoming json string and attached the object to req.body
29
What is the significance of an HTTP request's method?
Desired action to get from the resource. A server can do whatever it wants with the request.