Node.js Flashcards

1
Q

What is Node.js?

A

an open-source, asynchronous JavaScript runtime environment built on Chrome’s V8 JavaScript engine, which executes outside the 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

build scalable server side network applications

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

What is a REPL?

A

a read-eval-print loop is a language shell

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

PHP, Python, Ruby, Java, C#

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

What is a CLI?

A

command line interface, a text-based user interface

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

What is a GUI?

A

graphical user interface

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

Give at least one use case for each of the commands listed in this exercise.

A

man -read about a command in the manual
cat -combine text files, print out
ls -list contents of a directory
pwd -view current directory
echo -write a string to a text file, command line
touch -create a new text file, updated access stamp on files
mkdir -create a new directory
mv -move a file to another directory, rename files
rm -remove a file from the hard drive
cp -copy a file

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

What is a computer process?

A

the instance of a computer program that is being executed by one or more threads

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

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

A

~200

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

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

A

a full stack web app is made form multiple processes together

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

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

A

access it directly with ‘process’ in Node.js, since it is a global object

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

What is a JavaScript module?

A

a single JavaScript file

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

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

A

parameters: exports, require, module, __filename, __dirname

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

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

A

clearImmediate(immediateObject)
console
process

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

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

A

to export code to be used in another module

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

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

A

by calling the require() function (with the argument being a string of the path to the JavaScript file) and assigning the return to a variable

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

What is the JavaScript Event Loop?

A

a cycling process for how JavaScript executes code in a non-blocking manner, checks if there is something in the call stack again and again, and if not then checks the callback queue (which is made up of completed web APIs),
-if there is something in the queue, it gets moved to the call stack

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

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

A

blocking code waits for each line of code to be resolved in the call stack, while non-blocking code moves code off to a task queue so that the call stack is not blocked from continuing to run

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

What is a directory?

A

a pointer or container for files

24
Q

What is a relative file path?

A

the location of a file from the current file

25
What is an absolute file path?
a complete path, the location of a file from anywhere | starts with a slash /
26
What module does Node.js include for manipulating the file system?
fs module
27
What method is available in the Node.js fs module for writing data to a file?
the fs.writeFile() method
28
Are file operations using the fs module synchronous or asynchronous?
asychronous on fs module, though both are possible in node
29
stdin
process input
30
stdout
process output for normal output (logs to the terminal), ex. process.stdout.write()
31
stderr
process output for errors
32
TCP
machines connect to a network, then can connect to each other, sending data back and forth
33
What is a client?
a program or computer which is a data requestor or accesses a service, or a web browser
34
What is a server?
a program or computer which is a data provider or provides functionality to clients
35
Which HTTP method does a browser issue to a web server when you visit a URL?
GET method
36
What is on the first line of an HTTP request message?
HTTP method, request target, HTTP version
37
What is on the first line of an HTTP response message?
protocol version, status code, status text
38
What are HTTP headers?
additional information which specifies the request or describe the body included in the message
39
Is a body required for a valid HTTP message?
No, it's optional
40
What is NPM?
a JavaScript package manager, CLI, website, software registry
41
What is a package?
a file in a directory with a package.json, reusable code which can be shared
42
How can you create a package.json with npm?
the CLI command "npm init --yes"
43
What is a dependency and how do you add one to a package?
- a package that your app relies on to function | - npm install
44
What happens when you add a dependency to a package with npm?
the package and any of its dependencies are installed in the 'node-modules' folder, also altering the package.json file
45
How do you add express to your package dependencies?
npm install express
46
What Express application method starts the server and binds it to a network PORT?
app.listen([port[,host[,backlog]]][,callback])
47
What is Express?
back end web application framework for Node.js
48
How do you mount a middleware with an Express application?
app.use([path,] callback [,callback...]) method
49
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req (request) and res (response) objects
50
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
51
What is the significance of an HTTP request's method?
HTTP request methods mean what we want to do, but can actually do anything
52
What does the express.json() middleware do and when would you need it?
- parses the JSON request body to a JavaScript object | - when you will receive JSON from the request body
53
npm run dev:server
- nodemon watches js so it auto restarts server
54
Promise
an object representing the eventual completion or failure of asynchronous operation
55
What are the three states a Promise can be in?
pending, fulfilled, rejected
56
How do you handle the fulfillment of a Promise?
.then() method, pass a handler function as an argument
57
How do you handle the rejection of a Promise?
.then() or .catch() method, pass a handler function as an argument