Node Flashcards

1
Q

What are the 3 components of a fullstack Web architecture?

A

Front-end server, application server, back-end server.

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

What is Node.js?

A

Node.js is a back-end JavaScript runtime environment

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

What can Node.js be used for?

A

back-end

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

What is a REPL?

A

Read-Eval-Print-Loop (REPL) is an easy-to-use command-line tool, used for processing Node. js expressions

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

What backend languages have you heard of?

A

Python, PHP, Ruby, Java, C++

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

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

A

100+

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

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

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

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

A

The process 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
11
Q

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

A

console.log(process)

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

How do you access the command line arguments in a Node.js program?

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

What is a JavaScript module?

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

What are the advantages of modular programming?

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

In JavaScript, how do you make a function in a module available to other modules?

A

export keyword

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

In JavaScript, how do you use a function from another module?

A

import keyword.

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

What is the JavaScript Event Loop?

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

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

A

Blocking refers to operations that block further execution until that operation finishes while non-blocking refers to code that doesn’t block execution. Or as Node. js docs puts it, blocking is when the execution of additional JavaScript in the Node. js process must wait until a non-JavaScript operation completes.

20
Q

What is a directory?

A

a folder/container that holds files.

21
Q

What is a relative file path?

A

a file in the same directory

22
Q

What is an absolute file path?

A

always starts at the root of the file path.

23
Q

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

A

fs-module

24
Q

What method is available in the node:fs module for reading data from a file?

A

readFile(FILEPATH, OPTION)

25
Q

What method is available in the node:fs module for writing data to a file?

A

writeFile(fileneame, data)

26
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous because file operations are slow. So they are asynchronous to avoid blocking.

27
Q

What is NPM?

A

Node Package Manager.

28
Q

What is a package?

A

A directory with one or more files that usually have bit of code inside.

29
Q

How can you create a package.json with npm?

A

npm init –yes

30
Q

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

A

its a package that you depend on. npm install package-name

31
Q

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

A

Adds package name into dependencies field into package.json and creates a node_modules directory where the package is put and its dependencies.

32
Q

What are some other popular package managers?

A

Yarn, PNPM,

33
Q

What is Express useful for?

A

Useful for implementing routes or endpoints.

34
Q

How does Express fit into a full-stack web application?

A

On server side, manages the http requests.

35
Q

How do you add express to your package dependencies?

A

npm install express

36
Q

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

A

the listen() method
a port is an endpoint of a communication in an operating system. Specific port numbers are often used to identify specific services.

37
Q

What is Express middleware?

A

a function that takes in a request, does something, then calls next or response.

38
Q

What is Express middleware useful for?

A

changing http requests and then returning a response???

39
Q

How do you mount a middleware with an Express application?

A

Pass the middleware function through app.use

40
Q

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

A

the request, the response, and the next function

41
Q

What is an API endpoint?

A

a URL with API at the end.
the endpoint is the end of the URL.

42
Q

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

A

application/json

43
Q

What is the purpose of the Express Static middleware?

A

To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express. Express static sets up middleware that checks to see if a file exists and then calls sendFile on it.

44
Q

What does express.static() return?

A

a middleware function.

45
Q

What are several examples of static files?

A

Any kind of file can be served as static content as long as it does not change in response to a user’s actions or inputs. This includes images, JavaScript files, CSS files, videos, Flash files, even web pages.

46
Q

What is a good way to serve application images using Express?

A

use the express.static built-in middleware function