Node/Express/Fetch Flashcards

1
Q

What is Node.js?

A

Node.js is a program that allows JS to be run outside of a web 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

commonly used to build 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

read-eval-print loop. 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. browser console is REPL.

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: These are interpreted on-the-fly
jit - just in time compilation
JavaScript (jit), Ruby (jit), Elixir, PHP, Python, Perl, Erlang
what to learn after BootCamp: TYPESCRIPT, any other languages job rec.

Memory Managed Languages: These languages are compiled ahead of time
Java/Kotlin, C#, Golang, Haskell, Julia, F#, Fortan

Manual Memory Management: ahead of time compiled (low-level language)
C++, C, Swift, Rust, D, Zig

SQL - for Database

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

The process object in Node. js is a global object that can be accessed inside any module without requiring it

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

execute the node command with the js file that has the console.log(process); in it… or maybe process

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

an 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 single JS file.
A file containing related code. technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

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

exports (object), require (function), module (object), __filename (string), __dirname (string)

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

console, process, global

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

The main purpose of module. exports is to achieve modular programming. Modular programming refers to separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

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

call the require function and get the relative path as argument and assign it to a variable.

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

What is the JavaScript Event Loop?

A

responsible for collecting the event and running when the stack is empty. event loop looks at the task queue and pushes it back to stack when stack is empty (call stack is cleared).

look at stack and look at the task queue, if stack is empty, it takes the first thing on the queue and pushes it on to the stack ONCE everything on the stack is cleared. which effectively runs it. stacks up on task queue(s) / call back queue and pushes it back to stack to be run.

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

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

A

blocking: synchronous. need to wait for a process to finish before the next line of code runs. it blocks the next code to run until the current is finished. blocking is occupying the call stack so it can’t do anything until it’s cleared. anything occupying the call stack is blocking.

non-blocking: asynchronous callbacks. is able to run other code/thing while it’s running one code/thing.

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

What is a directory?

A

it is a file directory

17
Q

What is a relative file path?

A

path to somewhere from where the current file

18
Q

What is an absolute file path?

A

starts with a root of the file system “/”

19
Q

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

A

fs module.

20
Q

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

A

writeFile

21
Q

Are file operations using the fs module synchronous or asynchronous?

A

both synchronous and asynchronous

22
Q

How do you add express to your package dependencies?

A

make sure to create a package.json first with “npm init” command
after that use “npm install express”

23
Q

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

A

listen() method.

var express = require(‘express’)
var app = express()
app.listen(3000)

24
Q

How do you mount a middleware with an Express application?

A

use() method

25
Q

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

A

request object and response object
req is a data model of HTTP request message (FROMthe client)
res is a data model of the HTTP response message (TO the client)

26
Q

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

A

application/json.

27
Q

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

A
28
Q

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

A

It parses incoming requests with JSON payloads. Returns middleware that only parses JSON and only looks at requests where the content-type header matches the type option.

29
Q

What does express.static() return?

A

method of express object that returns a function.
express.static(publicPath) returns a function

is a built-in middleware function in Express, syntax
express.static( root, [options] )

30
Q

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

A

absolute path to the current module’s directory

31
Q

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

A

combines the paths together.

joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path

32
Q

What does fetch() return?

A

a promise. promised to get a response (res). a server responded, here is the response message

33
Q

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

A

‘GET’ request.

34
Q

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

A

const request = {
method: ‘POST’

};

as [option], a second argument.

35
Q

When does React call a component’s componentDidMount method?

A

after the successful render() . it has finished loading the render() method,

36
Q

Name three React.Component lifecycle methods.

A

constructor()
render()
componentDidMount()
componentDidUpdate()
componentWillUnmount()

37
Q

How do you pass data to a child component?

A

through props

Userlist users(<- this is the prop that will be passed)