Node.js Flashcards

1
Q

What is Node.js?

A

allows you to do js outside of 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 and launch apps from your computer

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 that allows you to input commands, execute them, and return results

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

C++ python C ruby go javascript java

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

What is a computer process?

A

it is an 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
7
Q

Roughly how many computer processes are running on your host operating system?

A

6 apps running, 132 background processes

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

know what sort of burden you are putting on a computer with your app

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

The projcess object is a global that provides information about, and control over, the current Node.js process. As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require()

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

You can access it by using console logging it or you can access it’s children by index
it is global so you can access it whenever

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 JS module?

A

a simple part of a more complex, larger system

a file within many files for 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, require, module, __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

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

move code between files

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

use require

17
Q

What is the JavaScript Event Loop?

A

it is essentially a a queue of commands that are waiting to be run after the call stack has been filled and emptied

18
Q

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

A

blocking is essentially code that is synchronous while nonblocking is code that is asynchronous

19
Q

What is a directory?

A

a folder

20
Q

What is a relative file path?

A

the url of a file that is relative to the url of the file that you are using

21
Q

What is an absolute file path?

A

the absolute file path is the exact route of the file in question

22
Q

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

A

fs

23
Q

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

A

fs.writeFile

24
Q

Are file operations using the fs module synchronous or asynchronous?

A

both

25
Q

What is NPM?

A

it stands for node package manager and it is a software registry where you can share packages

26
Q

What is a package?

A

packages are reusable code, and are sometimes called modules
a package.json file:
- lists the packages your project depends on
- specifies versions of a package that your project can use using semantic versioning rules
- makes your build reproducible, and therefore easier to share with other developers

27
Q

How can you create a package.json with npm?

A

make sure that you are in your root directory and you need to run npm init
to make a default package.json using information extracted from the current directory, use the npm init command with the –yes or -y flag

28
Q

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

A

this is a package that your code depends on; when you run npm install, npm will download dependencies and devDependencies that are listed in package.json that meet the semantic version requirements listed for each

29
Q

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

A

it gets added to the node-modules directory that is either in your directory or newly created, and it is listed as a dependency in the package.json file

30
Q

How do you add express to your package dependencies?

A

npm install express

31
Q

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

A

listen

32
Q

How do you mount a middleware with an Express application?

A

use method

33
Q

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

A

request and response

34
Q

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

A

application/json