Node Flashcards

1
Q

What is Node.js?

A

a program that allows JavaScript to be run outside of a web browser. Node.js is powered by V8; the same JavaScript engine in the Google Chrome browser. It is free, open-source software and its source code is available on GitHub.

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

It is commonly used to build scalable back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.

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

What is a REPL?

A

A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, 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
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

Node.js, PHP, Ruby, Python, Java

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

What is a computer process?

A

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
7
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
8
Q

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

A

a global that provides information about, and control over, the current Node.js process.

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

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

A

You can access it directly as it is a global object which means it is available to all Node.js applications

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

What is the data type of process.argv in Node.js?

A

object

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

What is a JavaScript module?

A

A single .js file

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

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

A
\_\_dirname 
\_\_filename
exports
module
require(id)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

AbortSignal

clearImmediate(immediateObject)

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

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

A

To allow a module to export functions or variables in which another module can import it through require() in Node.js

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

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

A

You export the functionality you need by assigning the value of the functionality to the export object. You then import the functionality by assigning the return of the require function to a local variable in your destination module.

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

What is the JavaScript Event Loop?

A

one of the four major concepts that sets JavaScript apart from many other languages. The order is a callback function is added to the stack but is then popped off and sent to the web API. It is then sent to the event queue when it will wait to be called. Once the call stack is empty, the first item in the event queue is pushed to the stack and execute.

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

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

A

Blocking is when the code has to wait on a function to execute fully first before the rest of the code can run. Non-blocking is when the the function is sent to another thread so the code can continue running without waiting

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

What is a directory?

A

AKA folders. It allow the user to group files into separate collections

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

What is a relative file path?

A

The path to a specific file relative to the current directory

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

What is an absolute file path?

A

The path to a specific file from the root directory

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

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

A

File System module

22
Q

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

A

writeFile

23
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous

24
Q

What are default params?

A

When defining a function, you can set a parameter to use a default value in case if the function is called without an argument.

Ex: function square(a=6, b) {
random code
}

25
Q

What is a spread in function calls?

A

It expands an iterable (array, string, etc) into a list of arguments

Ex:
const nums = [1, 2, 3];
Math.max(…nums);
// This returns 3

26
Q

What is a spread in array literals?

A

It creates a new array using an existing array. Spreads the elements from one array into a new array.

Ex:
const nums1 = [1, 2, 3];
const nums2 = [a, b, c];
const nums3 = [...nums1, nums2];
//nums3 = [1, 2, 3, a, b, c]
27
Q

What is a spread in Javascript?

A

The spread syntax ( … ) allows an iterable, such as arrays or strings, to be expanded in usage as arguments for function calls, or elements for arrays

28
Q

What is a spread in object literals?

A

It copies properties from one object into another object.

Ex:
const feline = { legs: 4, family: 'Felidae' };
const lion = { ...feline, genus: 'Panthera' };
//lion = {legs: 4, family: 'Felidae', genus: 'Pantera' };
29
Q

What are rest params?

A

It collects all remaining arguments into an actual array

30
Q

What is NPM?

A

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.

31
Q

What is a package?

A

bits of reusable code from the npm repository

32
Q

How can you create a package.json with npm?

A

npm init –yes

33
Q

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

A

A dependency is another package that your package needs in order to work.

You add one by using the npm install command in Node.

34
Q

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

A

The package.json file is updated to include the dependency and a node_modules directory is added with the dependency package installed

35
Q

How do you add express to your package dependencies?

A

Install it through npm ie npm install express

36
Q

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

A

the listen method ie app.listen

37
Q

How does array destructuring work?

A
const score = [10, 8, 5, 4, 1]
const [gold, silver, bronze] = scores;
38
Q

How does object destructuring work?

A
const runner {
first: "Eliud",
last: "Kipchoge",
country: "Kenya",
title: "Elder of the Order of the Golden Heart of Kenya"
}
const {first, last, country } = runner;

const {title: otherName} = runner; // this destructures the title property from the object but assigns it to a variable named otherName ie this allows us to rename the variables

//NOTE: Default values can be assigned to variables if there isn’t a corresponding property from the object

first; //”Eliud”
last; //”Kipchoge”
country; //”Kenya”

39
Q

How does param destructuring work?

A
const person1 = {
firstName: 'Jimmy',
lastName: 'Smith',
age: 25
}
function fullName ( { firstName, lastName } ) {
 return ${firstName} ${lastName};
}
40
Q

What is a client?

A

A service requester like a browser

41
Q

What is a server?

A

Provider of resource or service

42
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

GET

43
Q

What is on the first line of an HTTP request message?

A

A start-line describing the requests to be implemented,

44
Q

What is on the first line of an HTTP response message?

A

A start-line declaring the status of a request on whether if it was successful or a failure

45
Q

What are HTTP headers?

A

Information in an HTTP message specifying the request, or describing the body included in the message.

46
Q

Is a body required for a valid HTTP message?

A

No

47
Q

How do you mount a middleware with an Express application?

A

Bind the middleware by using the app.use() and app.METHOD() functions

48
Q

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

A

the request object, the response object, and the next middleware function of the cycle

49
Q

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

A

application/json

50
Q

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

A

It returns middleware that only parses incoming requests with JSON payloads. This allows the app to already have JSON data that has already been parsed to use.

51
Q

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

A

It gives the app instruction on what the user’s request wants