Node.js Flashcards

1
Q

What is Node.js?

A

Node is a program that allows JavaScript to run outside of the 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

Node can be used to build back end web apps, command line programs.

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

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

What is a computer process?

A

The instance of a computer program that is being executed by one or many threads.

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

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

A

Full stack development depends on many processes working together to form an app. So understanding what these processes are doing or at least are running is important.

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

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

A

It is a global object that has information and control over the current node process.

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

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

A

Since it’s a global object, you can access it simply by typing process.

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

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

A

The data type is an array.

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

What is a JavaScript module?

A

A single js file. Each file is a small part of many other modules that come together to be a program.

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

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

A

__dirname, __filename, exports, module, require.

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

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

A

global and process

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

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

A

So that module file knows it is going to be allowing other modules to pair/group up with it.

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

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

A

The require method is used in the module that wants to use a functionality thats from another module.

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

What is the JavaScript Event Loop?

A

The event loop is how the JavaScript runtime pushes asynchronous callbacks onto the stack once the stack is cleared.

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

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

A

.

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

What is a directory?

A

It is a file that holds all other files.

17
Q

What is a relative file path?

A

A relative file path doesn’t have the forward slash.

18
Q

What is an absolute file path?

A

An absolute file path starts with the forward slash /

19
Q

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

A

fs

20
Q

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

A

fs.writeFile

21
Q

Are file operations using the fs module synchronous or asynchronous?

A

Both depending on which operation is being used.

22
Q

What is NPM?

A

NPM allows users to share their js code to others.

23
Q

What is a package?

A

A package contains modules that are often small. The package contains a small building block to solve a problem.

24
Q

How can you create a package.json with npm?

A

By being in the root directory and then using the command “npm init –yes”

25
Q

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

A

Packages that are required by your application in production. Use “npm install (name of package) “

26
Q

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

A

Your package.json gets updated with the dependency you just installed.

27
Q

How do you add express to your package dependencies?

A

npm install express

28
Q

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

A

The listen() method on the variable that holds the express function.

29
Q

How do you mount a middleware with an Express application?

A

By using the use method on the Express application.

30
Q

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

A

A callback function to run a block of code everytime there is a req and res.

31
Q

What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?

A

.

32
Q

What does the express.json() middleware do and when would you need it?

A

.

33
Q

What is the significance of an HTTP request’s method?

A

It allows the user to properly access the server. If the request method didn’t have the proper functionality, it would be extremely problematic.

34
Q

What does express.static() return?

A

.

35
Q

What is the local __dirname variable in a Node.js module?

A

.

36
Q

What does the join() method of Node’s path module do?

A

.