SENIOR SIDE Flashcards

1
Q

ES6-CONST-LET

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

A

a code block is anything within curly braces.

i.e. function code block, if statements, etc.

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

ES6-CONST-LET

What does block scope mean?

A

it means that variable declared within the code block are only for that block, i.e. local vs global variables

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

ES6-CONST-LET

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

ES6-CONST-LET

What is the difference between let and const?

A

VAR Yes Yes Function Scope Yes
LET Yes No Block Scope No
CONST No No Block Scope No

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

ES6-CONST-LET

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

A

When you’re adding to an array or object you’re not re-assigning or re-declaring the constant, it’s already declared and assigned, you’re just adding to the “list” that the constant points to.

ex: we are not changing the typeof in the variable

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

ES6-CONST-LET

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

A

whether or not you ever want that variable to be redeclared or reassigned???

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

ES6-TEMPLATE-LITERALS

What is the syntax for writing a template literal?

A

` some text and ${some variable or property}`

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

ES6-TEMPLATE-LITERALS

What is “string interpolation”?

A

string interpolation is the process of evaluating a string literal containing one or more placeholders ${someVariable}, yielding a result in which the placeholders are replaced with their corresponding values.

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

ES6-DESTRUCTURING

What is destructuring, conceptually?

A

it is breaking down an object or array and assigning key/value pairs to a variable/value pair

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

ES6-DESTRUCTURING

What is the syntax for Object destructuring?

A

name = {
firstName: ‘Andy’,
lastName: ‘Chen’
}

const { firstName, lastName } = name
- this creates a variable named firstName with value of name.firstName and variable named lastName with a value of name.lastName

const { myName: firstName } = name
- this creates a variable named myName with value of name.firstName

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

ES6-DESTRUCTURING

What is the syntax for Array destructuring?

A

const someArray = [0 , 1, 2, 3, 4]

const [number1, number2, number3] = someArray

or to get the last ones after number3 then
const [ , , , number4] = someArray

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

ES6-DESTRUCTURING

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

A

braces on the right side of the equal sign are creating

braces on left-hand side and that’s destructuring

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

ES6-ARROW-FUNCTIONS

What is the syntax for defining an arrow function?

A

const functionName = parameter => expression

or const functionName = (param1, param2) => param1 + param2

or const functionName = (param1, param2) => ( {param1:param2} )

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

ES6-ARROW-FUNCTIONS

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

A

it has an implicit return

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

ES6-ARROW-FUNCTIONS

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

A

arrow functions have a lexical scope (using global variables) so the value of ‘this’ is determined by the surrounding scope.

i.e. either window if it’s a global scope or local variable if arrow function is wrapped in a regular function

tim : arrow function = ‘this’ is defined at definition time
regular function = ‘this’ is defined at call time

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

COMMAND-LINE-BASICS

What is a CLI?

A

command line interface

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

COMMAND-LINE-BASICS

What is a GUI?

A

Graphical user interface

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

COMMAND-LINE-BASICS

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 = ultimate guide
cat = combine files
ls = check file directories
pwd = print current working directory
echo = print to terminal, like a console.log
touch = create a new file
mkdir = make directories / files
mv = move and renames file
rm = remove a file
cp = copy a file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

COMMAND-LINE-BASICS

What are the three virtues of a great programmer?

A

laziness, impatience, and hubris???

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

NODE-INTRO

What is Node.js?

A

Node.js is a javascript runtime. A program that allows JavaScript to be run outside of a web browser.

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

NODE-INTRO

What can Node.js be used for?

A

non-blocking, event driven servers

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

NODE-INTRO

What is a REPL?

A

read-eval-print loop, interactive top level or language shell

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

NODE-INTRO

When was Node.js created?

A

2009

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

NODE-INTRO

What back end languages have you heard of?

A

Python, MySQL, Node.js

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
NODE-PROCESS-ARGV What is the process object in a Node.js program?
It is an essential component in the Node.js ecosystem as it provides various information sets about the runtime of a program.
26
NODE-PROCESS-ARGV How do you access the process object in a Node.js program?
``` const process = require('process'); or just using process since it's global ```
27
NODE-PROCESS-ARGV What is the data type of process.argv in Node.js?
, an array of strings
28
NODE-MODULE-SYSTEM What is a JavaScript module?
a JavaScript file containing related code
29
NODE-MODULE-SYSTEM What values are passed into a Node.js module's local scope?
exports, require, module, __filename, __dirname ``` ex: (function (exports, require, module, __filename, __dirname) { // your code is here }); ```
30
NODE-MODULE-SYSTEM Give two examples of truly global variables in a Node.js program.
setInterval, setTimeOut
31
NODE-REQUIRE What is the purpose of module.exports in a Node.js module?
to export functions to another node.js module
32
NODE-REQUIRE How do you import functionality into a Node.js module from another Node.js module?
const someVariable = require('./someFileName');
33
THE-EVENT-LOOP What is the JavaScript Event Loop?
An event loop is something that pulls stuff out of the queue and places it onto the function execution stack whenever the function stack becomes empty.
34
THE-EVENT-LOOP What is different between "blocking" and "non-blocking" with respect to how code is executed?
blocking = synchronous, won't allow the computer to do anything else until the code block is completely run through non-blocking = asynchronous can run other things while waiting
35
NODE-FS-READFILE What is a directory?
it is a path to what people call a folder
36
NODE-FS-READFILE What is a relative file path?
it is the actual file path to go from one directory to another
37
NODE-FS-READFILE What is an absolute file path?
a file path from the root
38
NODE-FS-READFILE What module does Node.js include for manipulating the file system?
fs module
39
NODE-FS-WRITEFILE What method is available in the Node.js fs module for writing data to a file?
writeFile method
40
NODE-FS-WRITEFILE Are file operations using the fs module synchronous or asynchronous?
asynchronous
41
HTTP-MESSAGES-RECAP What is a client?
a device that request services
42
HTTP-MESSAGES-RECAP What is a server?
something that responds to client requests
43
HTTP-MESSAGES-RECAP Which HTTP method does a browser issue to a web server when you visit a URL?
GET
44
HTTP-MESSAGES-RECAP What is on the first line of an HTTP request message?
start line (3 items) - http method (GET, PUT or POST) - URL - HTTP version ( HTTP/1.1)
45
HTTP-MESSAGES-RECAP What is on the first line of an HTTP response message?
protocol version, status code, status text
46
HTTP-MESSAGES-RECAP What are HTTP headers?
meta data formatted as key:value pairs
47
HTTP-MESSAGES-RECAP Is a body required for a valid HTTP message?
no
48
NPM-INTRO What is NPM?
stands for Node Package Manager - largest JS database of free code, used to share and download code - website, CLI, and registry
49
NPM-INTRO What is a package?
package.json and directory with 1 or more files in it
50
NPM-INTRO How can you create a package.json with npm?
npm init --yes
51
NPM-INTRO What is a dependency and how to you add one to a package?
something that the package will need to run and | to download it use npm install on command line
52
NPM-INTRO What happens when you add a dependency to a package with npm?
- dependencies object will be updated | - adds the node list to the package
53
EXPRESS-INTRO How do you add express to your package dependencies?
npm install express
54
EXPRESS-INTRO What Express application method starts the server and binds it to a network PORT?
listen method | - Binds and listens for connections on the specified host and port
55
EXPRESS-HELLO-WORLD How do you mount a middleware with an Express application?
use the 'use' method on an express object | i.e. app.use( )
56
EXPRESS-HELLO-WORLD Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req for request and res for respond
57
EXPRESS-GET-JSON What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
58
EXPRESS-POST-JSON What does the express.json() middleware do and when would you need it?
parses incoming json body and need it when parsing incoming json bodies
59
EXPRESS-DELETE What is the significance of an HTTP request's method?
tells the server if you're getting or posting
60
POSTGRES-INTRO What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a relational database management system, mysql, SQL server by Microsoft, and Oracle by Oracle Corporation
61
POSTGRES-INTRO What are some advantages of learning a relational database?
RDBMS VS non relational good at securing data and making complex queries vs non relational is better at storing more massive data they're everywhere, if you learn one, you basically know them all
62
POSTGRES-INTRO What is one way to see if PostgreSQL is running?
sudo service postgresql status
63
POSTGRES-DATABASE What is a database schema?
a collection of related tables
64
POSTGRES-DATABASE What is a table?
list of rows with related attributes
65
POSTGRES-DATABASE What is a row?
a set of attributes (columns)
66
SQL-SELECT What is SQL and how is it different from languages like JavaScript?
SQLstands for Structured Query Language and it's different from JavaScript because it's a declarative langauge. SQL is like HTML and CSS where you describe the results and the programs renders the results.
67
SQL-SELECT How do you retrieve specific columns from a database table?
SELECT "thisColumn", "thatColumn" | FROM thisTable;
68
SQL-SELECT How do you filter rows based on some specific criteria?
SELECT "thisColumn", "thatColumn" FROM thisTable WHERE "thisColumn" > 1;
69
SQL-SELECT What are the benefits of formatting your SQL?
looks cleaner and easier to read
70
SQL-SELECT What are four comparison operators that can be used in a where clause?
<, >, =, !=
71
SQL-SELECT How do you limit the number of rows returned in a result set?
at the very bottom LIMIT clause; SELECT "thisColumn", "thatColumn" FROM thisTable WHERE "thisColumn" > 1 LIMIT 5;
72
SQL-SELECT How do you retrieve all columns from a database table?
SELECT * | FROM thisTable;
73
SQL-SELECT How do you control the sort order of a result set?
order by clause can use desc or ascending is default
74
SQL-INSERT How do you add a row to a SQL table?
insert into "table" ("col1", "col2") | values ('hello', 'world');
75
SQL-INSERT What is a tuple?
a list of values
76
SQL-INSERT How do you add multiple rows to a SQL table at once?
insert into "table" ("col1", "col2") values ('hello', 'world'), ('something', 'else');
77
SQL-INSERT How do you get back the row being inserted into a table without a separate select statement?
insert into "table" ("col1", "col2") values ('hello', 'world'), ('something', 'else') returning *; <--- the returning clause with * to return all.
78
SQL-UPDATE How do you update rows in a database table?
update "thisTable" set "name" = 'something' where "name" = 'else';
79
SQL-UPDATE Why is it important to include a where clause in your update statements?
so you dont accidentally chage the entire column
80
SQL-DELETE How do you delete rows from a database table?
delete from "table" where "name" = 'something' returning *; <-- returning clause is optional
81
SQL-DELETE How do you accidentally delete all rows from a table?
delete from "table";
82
SQL-JOIN What is a foreign key?
a foreign key is a column used in another table to link them
83
SQL-JOIN How do you join two SQL tables?
use the join clause select * from "thisTable" join "thisOtherTable" using ("thisColumn");
84
SQL-JOIN How do you temporarily rename columns or tables in a SQL statement?
use alias, can use them for more than just select statements select "firstName" as "first" from "thisTable" as "table" join "otherTable" as "other";
85
SQL-AGGREGATES What are some examples of aggregate functions?
MIN, MAX, SUM
86
SQL-AGGREGATES What is the purpose of a group by clause?
to group data that has unique values
87
ES6-PROMISES What are the three states a Promise can be in?
pending, fulfiled or rejected
88
ES6-PROMISES How do you handle the fulfillment of a Promise?
promise.then and pass a callback function
89
ES6-PROMISES How do you handle the rejection of a Promise?
promise.catch and pass a callback function
90
ARRAY-FILTER What is Array.prototype.filter useful for?
Creating a new array while excluding some elements.
91
ARRAY-MAP What is Array.prototype.map useful for?
Creating a new array containing the transformed elements of another.
92
ARRAY-REDUCE What is Array.prototype.reduce useful for?
Combining the elements of an array into a single value.
93
ES6-CLASSES What is "syntactic sugar"?
syntax that is designed to make things easier to read or to express.
94
ES6-CLASSES What is the typeof an ES6 class?
functions
95
ES6-CLASSES Describe ES6 class syntax.
``` class someName { constructor (var1, var2, var3) { this.var1 = var1; this.var2 = var2; this.var3 = var3; } ``` someFunction() { } }
96
ES6-CLASSES What is "refactoring"?
restructuring code without changing the purpose of the original code
97
WEBPACK-INTRO What is Webpack?
it is a module bundler for JS that transforms html, css, and images. Webpack takes modules with dependencies and generates static assets representing those modules.
98
WEBPACK-INTRO How do you add a devDependency to a package?
use --save-dev in the command line | ex: npm install --save-dev webpack
99
WEBPACK-INTRO What is an NPM script?
way to bundle common shell commands for your project
100
WEBPACK-INTRO How do you execute Webpack with npm run?
npm run build
101
ES6-MODULES How are ES Modules different from CommonJS modules?
ES Module = standard for JS ex: import, export CommonJS = default for Node.js ex: require
102
ES6-MODULES What kind of modules can Webpack support?
ECMAScript, CommonJS, and AMD module
103
REACT-ELEMENTS What is React?
a library for building UIs. React makes it easy to create interactive UIs.
104
REACT-ELEMENTS What is a React element?
a react element is what gets returned from components | a plain js object.
105
REACT-ELEMENTS How do you mount a React element to the DOM?
``` const root = ReactDOM.createRoot(container); root.render(div); ```
106
BABEL-INTRO What is Babel?
it is a compiler that transforms es6 JS to es5 JS to make it backwards compatible
106
BABEL-INTRO What is a Plug-in?
it is a software addon that enhances the program
107
BABEL-INTRO What is a Webpack loader?
allow you to pre-process files as you import or “load” them
108
BABEL-INTRO How can you make Babel and Webpack work together?
use npm i --save-dev babel-loader babel compiles the code and webpack runs the code
109
REACT-JSX What is JSX?
syntax extension to JavaScript that produces react "elements", structures UI similar to html
110
REACT-JSX Why must the React object be imported when authoring JSX in a module?
because internally every JSX is creating a React Component using JSX transformer
111
REACT-JSX How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
npm i --save-dev webpack npm i --save-dev babel-loader npm i --save-dev @babel/plugin-transform-react-jsx
112
REACT-FUNCTION-COMPONENTS What is a React component?
it is a function or a class whose job is to return react elements
113
REACT-FUNCTION-COMPONENTS How do you define a function component in React?
just like any other function but with first letter capital, but return what looks like html ``` function CustomButton() { return <.button>Click Me! <./button>; (remove dots. brainscape dont allow) } ```
114
REACT-FUNCTION-COMPONENTS How do you mount a component to the DOM?
``` const container = document.querySelector('#root'); const root = ReactDOM.createRoot(container); ``` root.render(<.CustomButton />);
115
REACT-PROPS-AND-EXPRESSIONS What are props in React?
Props (properties) are arguments passed into React components through HTML attributes
116
REACT-PROPS-AND-EXPRESSIONS How do you pass props to a component?
by typing it with the react component ``` ex: function CustomButton(props) { console.log(props.name) return {props.text}; } ``` <.CustomButton text="something" name="andy" />
117
REACT-PROPS-AND-EXPRESSIONS How do you write JavaScript expressions in JSX?
within curly braces { } | curly braces are how we escape JSX syntax into JS syntax
118
REACT-CLASS-COMPONENTS How do you create "class" component in React?
``` class Something extends React.Component { render(props) { return <.button> { props.text } <./button> } } ```
119
REACT-CLASS-COMPONENTS How do you access props in a class component?
???
120
REACT-EVENTS-AND-STATE What is the purpose of state in React?
to store information or data of react components
121
REACT-EVENTS-AND-STATE How do you pass an event handler to a React element?
pass as props (camelCase) pass the function ex: <.button onClick={this.function}><./button>
122
REACT-FORM-CONTROLS What are controlled components?
123
REACT-FORM-CONTROLS What two props must you pass to an input for it to be "controlled"?
124
REACT-RENDERING-LISTS What Array method is commonly used to create a list of React elements?
map method
125
REACT-RENDERING-LISTS What is the best value to use as a "key" prop when rendering lists?
126
EXPRESS-STATIC What does express.static() return?
returns an object
127
EXPRESS-STATIC What is the local __dirname variable in a Node.js module?
tells you the absolute path of the directory containing the currently file
128
EXPRESS-STATIC What does the join() method of Node's path module do?
join combines directories into an absolute file path
129
FETCH What does fetch() return?
fetches a resource from the network and returns a promise which is fulfilled once the response is available
129
FETCH What is the default request method used by fetch()?
a get request
130
FETCH How do you specify the request method (GET, POST, etc.) when calling fetch?
as the second optional parameter of fetch | ex: fetch ('someLink', {method: post})
131
FETCH-IN-REACT When does React call a component's componentDidMount method?
immediately after a component is mounted (inserted into the dom tree)
132
FETCH-IN-REACT Name three React.Component lifecycle methods.
componentsDidMount( ), componentsDidUpdate( ), componentWillUnmount( )
133
FETCH-IN-REACT How do you pass data to a child component?
by using props to pass data