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
Q

What is a JavaScript module?

A

a single .js file

26
Q

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

A

module, exports, require( ), __dirname, __filename

27
Q

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

A

process, global

28
Q

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

A

allows you to export functions and objects from a module to be used in another

29
Q

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

A

require( relative path to file)

30
Q

What is the JavaScript Event Loop?

A

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
Q

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

A

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
Q

What is a directory?

A

a collection of files

33
Q

What is a relative file path?

A

points to a file within the context of the current directory

34
Q

What is an absolute file path?

A

points to a file from the root directory

35
Q

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

A

fs

36
Q

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

A

.writeFile( )

37
Q

Are file operations using the fs module synchronous or asynchronous?

A

both

38
Q

What is NPM?

A

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
Q

What is a package?

A

a directory containing a program described by a package.json file, and a package.json file

40
Q

How can you create a package.json with npm?

A

npm init –yes

41
Q

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

A

another package a package needs in order to work, npm install

42
Q

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

A

package.json will be updated to include the dependency and the package for the dependency will be installed to the node_modules directory

43
Q

How do you add express to your package dependencies?

A

npm install express

44
Q

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

A

app.listen( )

45
Q

How do you mount a middleware with an Express application?

A

app.use( )

46
Q

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

A

req and res

47
Q

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

A

application/json

48
Q

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

A

returns a middleware function that parses JSON, attaches data to the body property of the req object, used when expecting requests with JSON

49
Q

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

A

describes the action the server has to perform

50
Q

What does express.static( ) return?

A

middleware function that serves files within a given root directory

51
Q

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

A

absolute file path of directory of current module

52
Q

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

A

join all given path segments