Node.js Flashcards

1
Q

What are the 3 components of a fullstack Web architecture?

A
  1. A front-end web server serving static content, and potentially some cached dynamic content. In web-based application, front end is the content rendered by the browser. The content may be static or generated dynamically.
  2. A middle dynamic content processing and generation level application server (e.g., Symfony, Spring, ASP.NET, Django, Rails, Node.js).
  3. A back-end database or data store, comprising both data sets and the database management system software that manages and provides access to the data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Node.js?

A

An asynchronous event-driven JavaScript runtime for backend servers that things talk to.

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

Run applications on the backend. Servers.

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. It is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise.

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

PHP, Ruby, C++, 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

In computing, 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

105

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

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. This will be extremely important when learning about applications made of multiple components, such as clients, servers, and databases.

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(). The process object is also an instance of EventEmitter.

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

Just call or use the variable since it is global and always available.

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

Object data type of an array. The elements in the array are always turned to 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

Destructure process.argv and take everything starting at index 2.

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

What is a JavaScript module?

A

A file that has JavaScript in it.

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

Break down code into smaller chunks and be more organized.

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 it so that other modules can import it.

17
Q

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

A

Import it then call it.

18
Q

What is the JavaScript Event Loop?

A

It looks at the stack and looks at the task queue, if the stack is empty/clear it takes the first thing in the task queue and pushes it onto the stack, which effectively runs it.

19
Q

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

A

Blocking is synchronous code that “blocks” the call stack which makes other things not able to run while it is executing while Non-Blocking is asynchronous code that is pushed to the task queue and runs when the stack is empty/clear, so it doesn’t hog the stack and block or lock the browser.

20
Q

What is a directory?

A

It is a folder or container that holds files or other directories.

21
Q

What is a relative file path?

A

A relative file path starts at the current working directory.

22
Q

What is an absolute file path?

A

An absolute file path always starts at the root. It always starts with a /

23
Q

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

A

The File System module.

24
Q

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

A

The readFile method.

25
Q

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

A

The writeFile method.

26
Q

Are file operations using the fs module synchronous or asynchronous?

A

They are asynchronous.

27
Q

What is NPM?

A

Node Package Manager. npm is the world’s largest software registry. Open source developers from every continent use npm to share and borrow packages, and many organizations use npm to manage private development as well.
npm consists of three distinct components: the website, the Command Line Interface (CLI), the registry.

28
Q

What is a package?

A

Bits of reuseable code, a directory with one or more files in it. Also called a module. Usually has the .js file and a package.json file which contains some metadata about the package.

29
Q

How can you create a package.json with npm?

A

On the CLI, navigate to the root directory of the package wit cd /path/to/package then run the command ‘npm init –yes’.

30
Q

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

A

It is any packages that a package depends on. You add one to a package by using the npm install command.

31
Q

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

A

The package.json file will denote that the package(s) are dependencies and a node_modules directory will be created in the root directory of the package, which will then download all packages it depends on recursively.

32
Q

What are some other popular package managers?

A

The most popular is Yarn, developed by Facebook (which also develops React and Jest). Another lightweight competitor gaining popularity is PNPM.

33
Q

What is a version?

A

SEMVER. three numbers. a.b.c the first letter is the major version. It changes whenever the package makes a breaking change. The second number is the minor version. It changes when they add functionality to the package in a backwards compatible way. The last letter is called the bugfix version. It changes if they fixed a bug.