Node.js Flashcards

1
Q

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

A

To export data from 1 js file to another

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

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

A

require();

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

What is the javaScript Event Loop?

A

design pattern that waits for and dispatches events or messages

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

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

A

blocking doesn’t allow other functions to execute

non-blocking does

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

What is a directory?

A

folder, collection of files

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

What is a relative file path?

A

paths relative to the current working directory

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

What is an absolute file path?

A

Complete directory list

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

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

A

File System

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

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

A

fs.writeFile

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

Are file operations using the fs module synchronus or asynchronous?

A

async

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

What is a client?

A

Request and receive services from a server

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

What is a server?

A

Provides functions or services

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

Which HTTP method does a browser issue to a web server when you visit a URL

A

GET

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

What is the first line of an HTTP request message?

A

Start line

http method

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

What is on the first line of an HTTP response message?

A

start-line

http method, status

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

What are HTTP headers?

A

additional information passed with an HTTP request

17
Q

Is a body required for a valid HTTP message?

18
Q

What is NPM?

A

Node Package Manager, provides hosting for packages

19
Q

What is a package?

A

file or directory containing Node modules

20
Q

How can you create a package.json with npm?

21
Q

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

A

dependencies are packages required by your app.

They must be listed as a dependency in the package.json. Can use npm i

22
Q

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

A

the dependency is downloaded and saved to the package.json

23
Q

How do you add express to your package dependencies?

A

npm i 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
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 is the significance of an HTTP request's method?
Indicate the desired action. I could use the same path, but have different functions based on the request method
29
What does the express.json() middleware do and when would you need it?
It parses request with json objects. When receiving json objects