senior side Flashcards

1
Q

What is a code block? What are some examples of a code block?

A

A code block is code within the curly braces

some examples would be function defenitions and if statements

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

What does block scope mean?

A

Block scope means that a variable is only available within the code block it was defined in

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

What is the scope of a variable declared with const or let?

A

Block scope

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

What is the difference between let and const?

A

let values are mutable and const variables are not

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

Why is it possible to .push() a new value into a const variable that points to an Array?

A

we are not changing the id of the array

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

How should you decide on which type of declaration to use?

A

let is anything you want to change and const remains the same and cant be changed

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

What is the syntax for writing template literals in ?

A

backticks ( )

${}

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

What is “string interpolation”?

A

String formatting: the ability to substitute part of the string for the values of variables or expressions. This feature is also called string interpolation.

inside a string we replace the value with the variable

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

What is destructuring, conceptually?

A

provides an alternative way to assign properties of an object to variables:

getting data from an object and storing in into variable

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

What is the syntax for Object destructuring?

A

const { firstName: fname, lastName: lname } = person;

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

What is the syntax for Array destructuring?

A

let [x, y, z] = getScores

variable name and the order their at is its index

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

How can you tell the difference between destructuring and creating Object/Array literals?

A

destructuing: brackets are on left hand side
creating: they are on the right

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

any chance you get to use destructuring then use it but dont have to use it all the time

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

what is the syntax for defining an arrow function

A

param => expression

var keyword function name = parameter => expression

let add = (x, y) => x + y;

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

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

Without braces, you can only use an single-line expression in the body of the arrow function.

implicitly returns a value

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

How is the value of this determined within an arrow function?

A

//An arrow function captures the ‘this’ value of its enclosing context.//

takes value of this from the function it was defined from

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

What is a CLI?

A

Command line Interface

to receive commands from a user in the form of lines of text

This provides a means of setting parameters for the environment, invoking executables and providing information to them as to what actions they are to perform

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

What is GUI

A

graphical user interface

is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, instead of text-based UIs, typed command labels or text navigation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
Give at least one use case for each of the commands listed in this exercise.
man
cat
ls
pwd
echo
touch
mkdir
mv
rm
cp
A

man man
to get the manual for the command we run
//
////
cat is used to read a file sequentially and print it to the standard output
concatenate files and print on the standard output
cat laziness.txt
//
ls -a -F
ls -a lists all contents in the working directory, including hidden files and directories

ls" on its own lists all files in the current directory except for hidden files. "ls *.
//
pwd to check and see the working directory you are on
//
echo "Hello World!"
prints out text
you can direct to new file with >
//
touch tag-your-it.txt
touch creates the blank file 
//
mkdir to make a directory
//
mv to move and rename files
//
rm to delte a file or directory
//
cp to copy a file or whole directory into a new name (-and-no-text >no-and-then-text)
//
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What are the three virtues of a great programmer?

A

laziness impatience hubris

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

cat command will print the file you give it after running cat name-of-file

pwd prints the working directory

cat laziness.txt impatience.txt hubris.txt > three-virtues.txt will create a new file named three-virtues.txt and store laziness, impatience and hubris

echo runs the string you give it right away
echo ‘Hello World!” > hello.txt will make a new file names hello.txt

mkdir command will make a directory

mv will change the name of a file
example: mv pokiemans pokemon

rm will delete a file or directort (BE CAREFUL)

cp will copy a file and give it another name if you would lie
example: cp no-and-then.txt and-then.txt
use the history command to check all the commands I ran previously

///
$ cat oceans.txt > continents.txt
> takes the standard output of the command on the left and redirects it to the file on the right.

///
ls -a lists all contents in the working directory, including hidden files and directories
///
mkdir
$ mkdir media
mkdir takes in a directory name as an argument, and then creates a new directory in the current working directory. Here we used mkdir to create a new directory named media/.
///
rm
$ rm waterboy.txt
rm deletes files. Here we remove the file waterboy.txt from the file system.
///
rm -r
$ rm -r comedy
rm -r deletes a directory and all of its child directories.

touch
$ touch data.txt
touch creates a new file inside the working directory. It takes in a file name as an argument, and then creates a new empty file in the current working directory. Here we used touch to create a new file named keyboard.txt inside the 2014/dec/ directory.

If the file exists, touch is used to update the modification time of the file

Use the ls command to list the contents of your current working directory. Try it again with the -a and -F options.
Use the ls command to list the contents of the lfz-staff/ directory. Try it again with the -a and -F options.

Use the pwd command to write your current working directory to a new file named i-was-here.txt like this:
pwd > i-was-here.txt

Use the echo command to print the string ‘Hello, World!’ to the terminal.
Use the echo command to write the string ‘Hello, World!’ to a new file named hello.txt like this:
echo ‘Hello, World!’ > hello.txt

Use the touch command to create a new file named tag-youre-it.txt.
Use the touch command to create a new file named boop.txt inside of the snoot/ directory (i.e. snoot/boop.txt).
Use the ls command to list the contents of the snoot/ directory.
mkdir
Use the ls command to list the contents of the lfz-staff/ directory and write the results to a new file at lfz-staff/contents.txt like this:
ls -aF lfz-staff > lfz-staff/contents.txt

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

main takeaway is it gets this from the parent scope

A

syntax of arrow function
have to be passing it as a callback function or define it in a variable

const add1 = (x,y) => {
return x + y
}

const result1 =add1(12,56)

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

Learned so far on senior side

A

const/let
template literals
arrow functions
destructuring

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

What is node.js?

A

Environment to run JavaScript code outside of the browser

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

What can Node.js be used for?

A

It is 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
26
Q

What is a REPL?

A

Read-eval-printLoop

takes input ,reads input , evaluates input, prints the results

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

When was Node.js created?

A

2009

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

What back end languages have you heard of?

A

c++, c#, ruby python,PHp

node, java, python, c#, php c++

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

What is the process object in node.js

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():

Gives information on whatever the current process running in Node.js is

gloablly accessable objec that contains info

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

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

A

passing in the process object as an argument

process is a variable

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

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

A

Array

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

The process.argv property returns an array containing the command line arguments passed when the Node.js process was launched. The first element will be process.execPath. See process.argv0 if access to the original value of argv[0] is needed. The second element will be the path to the JavaScript file being executed. The remaining elements will be any additional command line arguments.

A

process. argv[0] process.execpath
proces. argv[1]. path to the javascript file
proces. argv[2] will be any command line arguments you type

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

notes to remember

A

every application is a process
process object gives us info about app that is running

process.argv is array

allows us to access data within array
we dont care about index 1 or 2

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

What is a module?

A

In JavaScript, a “module” is a single .js file. Node.js supports modules using a system heavily influenced by CommonJS.

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

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

A

exports , require , module , __filename , __dirname

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

we will care most of exports and require function

module.exports

require is how we get stuff from other files

const add = (x,y) => x + y

module.exports = add

New file 
const add = require('./add')

console.log(‘Add result:’, add(4,5))

whatever exports is then thats what require is going to return

A

bunch of ways to export multipe things

module.exports = {
add:add
subtract: subtract
divide: divide
multiply: multiply
}

ops. add
module. exports starts as an empty object
exports. add = add
exports. subtract = subtract

can not reassign exports

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

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

A

The purpose is to export data to use in another file

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

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

A

use the require function and pass in the relative path of the file

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

parseInt does not include decimal coverts string to number

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

What is the JavaScript Event Loop?

A

the event loops job is to look at the stack and if it is empty it takes first thing in que and runs it

responsible for executing the code, collecting and processing events, and executing queued sub-tasks.

its the process of the call stack being emptied and then runs whats in the stack and pops it and repeats

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

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

A

blocking is any code that prevents anything else from happening

non-blocking code is something that is taking a long time we kinda push it over to the side so everything else can render

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

What is a directory?

A

A directory is a folder that contains files

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

What is a relative file path?

A

A path that links to something withi the same directory

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

What is an absolute file path?

A

a path that lead all the way to the root of the file

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

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

A

fs module

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

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

A

writeFile method

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

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous

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

if you have a number to a string then you dont need to stringify
it will all become a string

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

JSON.stringify(data,null,2)

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

FINAL PROJECT

A

create doc
name doc
put heading on top and share
follow instructions

create figma
rename it
share file with scott and give access

create account
name it database postgres
share with scott

PLANNING
come up with idea
CRUD
create read update delete
!!!!do not use third party API!!!

START USING CSS LIBRARIES
bootstrap has most utility classes
dsiplay position’
margin padding

BEST To do it about something we like
CAR WASH PAGE
WORKOUT PAGE

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

What is a client?

A

client is a piece of computer hardware or software that accesses a service made available by a server as part of the client-server model of computer networks

the one who is making the request

Program that makes request o another computer or program

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

What is a server?

A

a server is a piece of computer hardware or software (computer program) that provides functionality for other programs or devices, called “clients”.

A programm that listens to incoming response or request

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

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

A

GET Request

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

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

A

An HTTP method, a verb (like GET, PUT or POST) or a noun (like HEAD or OPTIONS), that describes the action to be performed. For example, GET indicates that a resource should be fetched or POST means that data is pushed to the server (creating or modifying a resource, or generating a temporary document to send back).

The request target, usually a URL, or the absolute path of the protocol, port, and domain are usually characterized by the request context. The format of this request target varies between different HTTP methods. It can be

The HTTP version, which defines the structure of the remaining message, acting as an indicator of the expected version to use for the response.

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

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

A

The protocol version, usually HTTP/1.1.

A status code, indicating success or failure of the request. Common status codes are 200, 404, or 302

A status text. A brief, purely informational, textual description of the status code to help a human understand the HTTP message.

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

What are HTTP headers?

A

HTTP headers are information about the request being made

connection: common value of keep alive

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

Is a body required for a valid HTTP message?

A

no

204 no content is when none send body

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

Package manager for javascript

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

What is a package?

A

collection of files that put together make up a single program or unit

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

How can you create a package.json with npm?

A

be in root of your directory and run

npm init –y’

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

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

A

Dependery is packages required to use in your code

npm install package name you want

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

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

A

it updated the json file to include the depency you just added

adds list of dependencies to your package.json

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

How do you add express to your package dependencies?

A

npm install express

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

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

A

listen method

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

if you run into a error with port then another port is listening on same part

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

How do you mount a middleware with an Express application?

A

app.use()

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

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

A

app object

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

EXPRESS

A

Bind application-level middleware to an instance of the app object by using the app.use() and app.METHOD() functions, where METHOD is the HTTP method of the request that the middleware function handles (such as GET, PUT, or POST) in lowercase.

ERROR HANDLING MIDDLEWARE

Error-handling middleware
Error-handling middleware always takes four arguments. You must provide four arguments to identify it as an error-handling middleware function. Even if you don’t need to use the next object, you must specify it to maintain the signature. Otherwise, the next object will be interpreted as regular middleware and will fail to handle errors.

Define error-handling middleware functions in the same way as other middleware functions, except with four arguments instead of three, specifically with the signature (err, req, res, next)):

app.use((err, req, res, next) => {
console.error(err.stack)
res.status(500).send(‘Something broke!’)
})

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

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

A

application JSON

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

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

A

HTTP defines a set of request methods to indicate the desired action to be performed for a given resource.

HTTP defines methods (sometimes referred to as verbs, but nowhere in the specification does it mention verb) to indicate the desired action to be performed on the identified resource.

72
Q

path is arbitrary but needs to make sense

path has to start with forward slash

url parameters are indicated by colon(can pass info in URL)
req.params.NAmeGiven

res.sendStatus() no content

A
73
Q

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

A

It parses incoming requests with JSON payloads and is based on body-parser.

Returns middleware that only parses JSON and only looks at requests where the Content-Type header matches the type option.

does: parses request body
needed: needed when we want to send data to our server

74
Q

Json middleware is a function

apply any middleWare by using app.use

everyrequest that comes in will run through jsonMiddleWare

post,put, patch will check to see if there is json data if there is then it will parse data in body

req.body is created by JSON middleware

A

if req.body is undefined then no jsonMiddleware was applied

test code first then start writing everything else

75
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS).

mySQL
microsoft sql
Oracle by Oracle Corporation

76
Q

What are some advantages of learning a relational database?

A

Easy Access to data
accurate
extremely used

Many problem domains can be modeled well using a relational database. If you are storing related data, then a relational database is probably a good first choice! For example, you may be storing data about students, teachers, courses, and classrooms. You can imagine that there are relationships between these things.

77
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status in terminal

78
Q

What is a relational database?

A

A system used to maintain relational databases is a relational database management system (RDBMS). Many relational database systems are equipped with the option of using the SQL (Structured Query Language) for querying and maintaining the database.[2]

79
Q

how to start postgresql

how to stop postgresql

A

sudo service postgresql start

sudo service postgresql stop

80
Q

psql -c ‘\l’ databases we have

pgweb starts another application
\ its own applicaton that someone built tool we use

A
81
Q

What is a database schema?

A

A collection of tables is called a schema. A schema defines how the data in a relational database should be organized. In relational databases, you typically have to define your schema up front and the database server will make sure that any data being written to the database conforms to that schema.

instruction s or layout of all our tables including column’s

describes our database

82
Q

What is a table?

A

columns and rows

83
Q

What is a row?

A

Each row, which represents a complete record of specific item data, holds different data within the same structure.

A row is where the data is stored
each row contains data

84
Q
A
  • d database
  • f execute file path to file

psql -d pagila -c ‘\dt’

85
Q

What is SQL and how is it different from languages like JavaScript?

A

SQL is a declarative programming language. In declarative languages, programmers describe the results they want and the programming environment comes up with its own plan for getting those results

SQL is the language we use to interact with the database
declarative language

86
Q

How do you retrieve specific columns from a database table?

A

select statement and gets the values you pass into it

87
Q

How do you filter rows based on some specific criteria?

A

Where clause to be more specific

88
Q

What are the benefits of formatting your SQL?

A

it is easier to query for specifics items

Easier to read

89
Q

What are four comparison operators that can be used in a where clause?

A

> < = !=

90
Q

How do you limit the number of rows returned in a result set?

A

use the limit keyword and give it a limit number

91
Q

How do you retrieve all columns from a database table?

A

with the *

92
Q

How do you control the sort order of a result set?

A

with the order by clause in the select statement

93
Q

How do you add a row to a SQL table?

A

insert into “Specify row” (‘name”, ‘description’)

values to insert

94
Q

What is a tuple?

A

list of values in parenthesis ()

95
Q

How do you add multiple rows to a SQL table at once?

A

after tuple comma and then another one

values within parenthesis seperated by comas

96
Q

How do you get back the row being inserted into a table without a separate select statement?

A

returning then specify which column we want to return

97
Q

How do you update rows in a database table?

A

update specify table and then
set keyword which columns we want to update
where clause to specify

98
Q

Why is it important to include a where clause in your update statements?

A

so that you do not update everything instead of a single row

99
Q

How do you delete rows from a database table?

A

delete from then what you want to delete

100
Q

How do you accidentally delete all rows from a table?

A

delete without where clause

101
Q
select :firstName:, 'lastname, title'
from "castMembers'
join 'actors using ('actorId')
join 'films' usiong ('filmId')
where "films".filmId = 1;
A
select :firstName:, 'lastname, title'
from "castMembers'
join 'actors using ('actorId')
join 'films' usiong ('filmId')
where 'actors'.'actorId' = 1;
102
Q

What is a foreign key?

A

Notice how each row in the “products” table has a “supplierId” column.

That column specifically refers to values in the “supplierId” column of the “suppliers” table

This is known as a foreign key.

columns that links 2 tables together

103
Q

How do you join two SQL tables?

A

join clause and column name they share

104
Q

How do you temporarily rename columns or tables in a SQL statement?

A

table name.name as new name

to rename table name. name as name we want

105
Q

What are some examples of aggregate functions?

A

min() sum()

106
Q

What is the purpose of a group by clause?

A

you want to separate rows into groups and perform aggregate functions on those groups of rows. This is done with a group by clause.

107
Q

What are the three states a Promise can be in?

A

pending,

fullfilled, rejected

108
Q

How do you handle the fulfillment of a Promise?

A

.then method pass it a callback

109
Q

How do you handle the rejection of a Promise?

A

.catch

110
Q

What is Array.prototype.filter useful for?

A

The filter() method creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.

Useful to filter out things that meet a certain code

creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function

allows us to filter an array

111
Q

What is Array.prototype.map useful for?

A

The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

Any time we want to transform data into new array

112
Q

What is Array.prototype.reduce useful for?

A

To reduce an array to a single value

gets the previous value from the

113
Q

What is “syntactic” sugar?

A

In computer science, syntactic sugar is

syntax within a programming language that is designed to make things easier to read or to express.

114
Q

What is the typeof an ES6 class?

A

function

115
Q

Describe ES6 class syntax.

A

class Person {

}

we can add methods

constructor method( )

116
Q

What is “refactoring”?

A

code refactoring is

the process of restructuring existing computer code—changing the factoring—without changing its external behavior

Cleaning up code without changing its behavior

117
Q
defining class name student 
class Student

const {firstName, lastName} = this
being detructured

A
118
Q

What is Webpack?

A

Used to take a bunch of javascript files into one file

119
Q

How do you add a devDependency to a package?

A

npm install –save-dev name of devDependency

120
Q

What is an NPM script?

A

An npm script is a convenient way to bundle common shell commands for your project.

They are typically commands, or a string of commands, which would normally be entered at the command line in order to do something with your application.

121
Q

How do you execute Webpack with npm run?

A

npm run build

add name of script at the end

122
Q

webpack is a tool we use

folder structure:
src
(where we write our code)
(web pack will look here)

dist folder (short for ditruubion)
html goes here
or css
all website files goes here

now called public

important note

all files have to be converted within src folder to use import statements

A
123
Q

How are ES Modules different from CommonJS modules?

A

ES modules are the standard for JavaScript, while CommonJS is the default in Node. js.

common js modules use the require keyword

I guess you can put commonJS uses the require keyword while ES doesnt and uses import
and export instead of module.exports

124
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules.

125
Q

Names exports can export multiple things but it has to be wrapped in curly braces and name must match within import

export default. import name doesnt matter

A
126
Q

What is React?

A

A JavaScript library for building user interfaces

127
Q

What is a React element?

A

React elements are plain objects that describe the DOM element

information inside to describe what it has in it

128
Q

How do you mount a React element to the DOM?

A

create root

render method on root and pass in the node

129
Q

What is Babel?

A

Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments. Here are the main things Babel can do for you:

Transform syntax
Polyfill features that are missing in your target environment (through a third-party polyfill such as core-js)
Source code transformations (codemods)

Babel can convert one version of javascript to another

130
Q

What is a Plug-in?

A

is a software component that adds a specific feature to an existing computer program.

131
Q

What is a Webpack loader?

A
Loaders are transformations that are applied to the source code of a module
They allow you to pre-process files as you import or “load” them.

Allows us to connect other applications into the web pack process

132
Q

How can you make Babel and Webpack work together?

A

npm install -D babel-loader @babel/core @babel/preset-env webpack

babel-loader

133
Q

Main takeaways from babel-intro exercise

Webpack takes a bunch of files and converts it into one

babel converts javascript

we can connect them both with babel-loader

they are both separate application

A
134
Q

What is JSX?

A

It is called JSX, and it is a syntax extension to JavaScript

Allows us to write html like syntax to describe our UI within our javascript

135
Q

Why must the React object be imported when authoring JSX in a module?

A

Fundamentally, JSX just provides syntactic sugar for the React.createElement(component, props, …children) function. The JSX code:

JSX uses the react component in order to implement jsx into react

JSX gets converted by babel

136
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

babel-loader and the regex as a test

plugins: [
‘@babel/plugin-transform-react-jsx’

137
Q

jsx code read

<h1>Hello</h1>

opening tag for the jsx h1 element with text content

A
138
Q

What is a React component?

A

Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

139
Q

How do you define a function component in React?

A
function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}
class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}
Any  funtion component that returns jsx
140
Q

How do you mount a component to the DOM?

A

ReactDOM.render then pass in the cusotm fucntion and what it should be attatched to(node)

pass it to render method

141
Q

What are props in React?

A

Pass custom data to your component.

Props are arguments passed into React components

Props are how we pass data into our components

142
Q

How do you pass props to a component?

A

state the component name and then name and value

143
Q

How do you write JavaScript expressions in JSX?

A

You can put any valid JavaScript expression inside the curly braces in JSX.

144
Q

How do you create “class” component in React?

A

with the class keyword then extends React.Component

145
Q

How do you access props in a class component?

A

with this.props

146
Q

class defenition for the class CustomButton that extends the component property of the react object

constructor(props) constructor method definition

this.setState()({
isClicked: true
})

<div>

</div>

A
147
Q

What is the purpose of state in React?

A

used to contain data or information about the component
A component’s state can change over time; whenever it changes, the component re-renders

State is there to track information about the component

148
Q

How to you pass an event handler to a React element?

A

you pass it a function and what event we want it to listen to

149
Q

What are controlled components?

A

inputs values who are controlled by react

150
Q

What two props must you pass to an input for it to be “controlled”?

A

onChange and value

151
Q

What Array method is commonly used to create a list of React elements?

A

map

152
Q

What is the best value to use as a “key” prop when rendering lists?

A

whatever is uniqe

typicallly id

outermost element needs the key property

153
Q

What does express.static() return?

A

function serveStatic

154
Q

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

A

It returns the folder path of the current JavaScript file. It returns the name the of current working directory.

gives us absolute path that the module is in

155
Q

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

A

The path.join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

156
Q

What does fetch() return?

A

A Promise that resolves to a Response object.

157
Q

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

A

Get

158
Q

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

A

you set it in the option object and then give it in the method property

159
Q

When does React call a component’s componentDidMount method?

A

componentDidMount() is invoked immediately after a component is mounted (inserted into the tree). Initialization that requires DOM nodes should go here. If you need to load data from a remote endpoint, this is a good place to instantiate the network request.

after te

160
Q

Name three React.Component lifecycle methods.

A

ComponentDidMount()
ComponentWillMount()
ComponetDidUpdate()

161
Q

How do you pass data to a child component?

A

via props

162
Q

What does the acronym FIFO mean?

A

First in first out

163
Q

What methods are available on a Queue data structure?

A

enqueue(value) - adds a value to the “back” of the queue

dequeue() - removes the “front” value from the queue and returns it

164
Q

What must you do to access the value at an arbitrary point in a queue (not just the “front”)?

A

You need to traverse the stack until you get where you want to go

165
Q

What does the acronym LIFO mean?

A

last in first out

166
Q

What methods are available on a Stack data structure?

A

Pop
Push
Peek

167
Q

What must you do to access the value at an arbitrary point in a stack (not just the “top”)?

A

You need to traverse the stack until you get where you want to go

168
Q

How are linked lists different from an array?

A

Linked lists are sequential access (like a queue), not random access (like an array).

169
Q

How would you access an arbitrary node in a linked list (not just the “head”)?

A

.next

170
Q

FOR DATA STRUCTURE QUEUES
enqueue(value) - adds a value to the “back” of the queue
dequeue() - removes the “front” value from the queue and returns it

A
171
Q

FOR LINKEDLIST

A

.data - contains the node’s value.
.next a reference to the next node in the list, if there is one. If there is no “next” node in the list, this property is typically set to null.

172
Q

What must the return value of myFunction be if the following expression is possible?
myFunction()();

A

return must be another function

173
Q
What does this code do?
const wrap = value => () => value;
A

sets value to the the next anonymous function

174
Q

In JavaScript, when is a function’s scope determined; when it is called or when it is defined?

A

when it is called

175
Q

What allows JavaScript functions to “remember” values from their surroundings?

A

This environment consists of any local variables that were in-scope at the time the closure was created.