Node.js Flashcards

1
Q

What is Node.js?

A

Runs on V8 engine and allows JS to run outside of a web browswer

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

Access JS in the backend

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 - simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user. (ex: browser console)

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

Scripting languages: PHP, Python, Ruby, Perl, Lua
Systems languages: C, C++, Rust, D, Zig
Byte code languages: Java, C#,

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

What is a computer process?

A

Instance of a program being executed.

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

100 or more

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

So they understand how much memory and moving parts of running. It’s part of potentially solving problems and writing viable code.

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 model of the node.js object that is running.

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

Its a global object that can be accessed inside any module without requiring it.

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

Its a file (.js)

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

exports, module, require, __filename, __dirname

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, console, url

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

Defines dependencies on other modules and makes it available.

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

Require function

17
Q

What is a directory?

A

Folder that contains files and directs users where to go. It is essentially a file that lists other files.

18
Q

What is a relative file path?

A

Points to another file within a file.

19
Q

What is an absolute file path?

A

Path that points to a full url outside of the current page. Starts from 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?

23
Q

What is NPM?

A

Open source package manager to share and use code:. Refers to one of three things: cli, registry, and website

24
Q

What is a package?

A

Directory with one or more files with a package.json file

25
How can you create a package.json with npm?
npm init
26
What is a dependency and how to you add one to a package?
Other packages that your code depends on | npm-install
27
What happens when you add a dependency to a package with npm?
Adds it to package.json file and adds a directory with code in it (ex: node_modules)
28
How do you add express to your package dependencies?
npm install express
29
What Express application method starts the server and binds it to a network PORT?
listen method
30
How do you mount a middleware with an Express application?
use method
31
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req, res
32
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json | Content Type signifies what data type is in the body.
33
What is the significance of an HTTP request's method?
Defines specific action between client and server
34
What does the express.json() middleware do and when would you need it?
Parses incoming requests to JSON. You would use when you have to handle a request with a body in JSON.
35
What does express.static() return?
Returns a middleware function
36
What is the local __dirname variable in a Node.js module?
Path to whatever directory you are in
37
What does the join() method of Node's path module do?
Join all path segments together into one path separated by "/"