node Flashcards

1
Q

What is Node.js?

A

its a javaScript runtime

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

running JS in the command line

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, playground for code

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

What back end languages have you heard of?

A

“scripting languages” (interpreted)
python, javascript, ruby,
php, perl,

“compiled” (machine code translated)
c, c++ golang, haskell, crystal, rust

partially compiled(jvm)
java, scala, closure, kotlin
partially compiled(
 c#, f#
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

info about and control over the current node process

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

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

A

grab out of thin air because it’s global

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

What is a JavaScript module?

A

a separate .js file used to separate and organize work that can be exported to and called upon by other modules and .js files in the directory

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

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

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

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

A

creating a global data model that’s accessible from other modules in your file library

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

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

A

assigning a require call with path to the file to a variable

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

What is a directory?

A

a special file that points to other files

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

What is a relative file path?

A

a path to a file from where you currently are

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

What is an absolute file path?

A

takes you from the root of the document to a specific file

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

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

A

fs module

18
Q

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

A

writeFile method

19
Q

Are file operations using the fs module synchronous or asynchronous?

A

yes, you get to choose which version to use

20
Q

What is NPM?

A

the website, the CLI, the registry

21
Q

What is a package?

A

a directory with a package.json file and one or more files in it

22
Q

How can you create a package.json with npm?

A

npm init –yes

23
Q

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

A

something you’re package will need to run,

npm install filename

24
Q

What happens when you

add a dependency to a package with npm?

A

it downloads the node modules to your local system

25
Q

How do you add express to your package dependencies?

A

npm i express

26
Q

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

A

.listen() method

27
Q

How do you mount a middleware with an Express application?

A

app.use method

28
Q

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

A

request obj and response obj(req, res)

29
Q

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

A

application/json

30
Q

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

A

to parse the incoming JSON requests, you’ll need it when you’re handling incoming JSON request bodies

31
Q

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

A

it defines the desired action to be performed at the given resource or path

32
Q

app.use is the catchall middleware

A

use them for anytime you want an express function to run everytime you run the stack

33
Q

What is Webpack?

A

a module bundler to package JS and makes it all useable for the web

34
Q

How do you add a devDependency to a package?

A

npm i –save-dev or npm i -D

35
Q

What is an NPM script?

A

a property in package.json to store terminal commands

36
Q

How do you execute Webpack with npm run?

A

npm run build

37
Q

What does express.static() return?

A

a middleware function

38
Q

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

A

an absolute path to the directory name of the current module

39
Q

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

A

joins path segments together into one useable filepath

40
Q

What does fetch() return?

A

a promise that resolves the response

41
Q

What is the default request method used by fetch()?

A

get

42
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A