Node.js Flashcards

1
Q

What is a code block? What are some examples of a code block?

A

section of code enclosed within { }, ex: function, conditional, loop

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

What is a CLI?

A

command-line interface, text-based

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

What is a GUI?

A

graphical-user interface, graphical icon-based

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

man

A

user manual for commands

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

cat

A

combine content of files

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

ls

A

shows content of directory

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

pwd

A

shows current directory

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

echo

A

prints out text on terminal, like console.log( )

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

touch

A

changes file timestamps, can be used to create a new file

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

mkdir

A

creates a new directory

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

mv

A

renames or moves a file

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

rm

A

deletes a file

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

cp

A

copies a file

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

What are the three virtues of a great programmer?

A

laziness, impatience, hubris

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

What is Node.js?

A

a program that allows JS to be run outside of a web browser

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

What can Node.js be used for?

A

it can be used for back-ends for Web applications, command-line programs anything with automation

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

When was Node.js created?

A

May 27, 2009

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

What is a computer process?

A

a process is 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
20
Q

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

A

480 processes

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

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

A

Full stack Web development is based on making multiple processes work together to form one application, so having at least a cursory awareness of computer processes is necessary

22
Q

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

A

a global that provides info about, and control over, the current Node.js process

23
Q

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

A

with or without require( )

24
Q

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

A

an array of strings of the command-line arguments

25
What is a JavaScript module?
a single .js file
26
What values are passed into a Node.js module's local scope?
module, exports, require( ), __dirname, __filename
27
Give two examples of truly global variables in a Node.js program.
process, global
28
What is the purpose of module.exports in a Node.js module?
allows you to export functions and objects from a module to be used in another
29
How do you import functionality into a Node.js module from another Node.js module?
require( relative path to file)
30
What is the JavaScript Event Loop?
the event loop looks at the call stack and the task queue; if the stack is empty, the event loop pushes the first thing on the queue into the stack
31
What is different between "blocking" and "non-blocking" with respect to how code is executed?
blocking means the code is occupying the call stack, non-blocking means the code is a Web API (network, DOM, events) and is pushed to the task queue
32
What is a directory?
a collection of files
33
What is a relative file path?
points to a file within the context of the current directory
34
What is an absolute file path?
points to a file from the root directory
35
What module does Node.js include for manipulating the file system?
fs
36
What method is available in the Node.js fs module for writing data to a file?
.writeFile( )
37
Are file operations using the fs module synchronous or asynchronous?
both
38
What is NPM?
website, CLI, registry that provides a way to reuse code from other developers, to share your code with them, and manage different versions of code
39
What is a package?
a directory containing a program described by a package.json file, and a package.json file
40
How can you create a package.json with npm?
npm init --yes
41
What is a dependency and how to you add one to a package?
another package a package needs in order to work, npm install
42
What happens when you add a dependency to a package with npm?
package.json will be updated to include the dependency and the package for the dependency will be installed to the node_modules directory
43
How do you add express to your package dependencies?
npm install express
44
What Express application method starts the server and binds it to a network PORT?
app.listen( )
45
How do you mount a middleware with an Express application?
app.use( )
46
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req and res
47
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
48
What does the express.json() middleware do and when would you need it?
returns a middleware function that parses JSON, attaches data to the body property of the req object, used when expecting requests with JSON
49
What is the significance of an HTTP request's method?
describes the action the server has to perform
50
What does express.static( ) return?
middleware function that serves files within a given root directory
51
What is the local __dirname variable in a Node.js module?
absolute file path of directory of current module
52
What does the join() method of Node's path module do?
join all given path segments