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
Q

NODE-PROCESS-ARGV

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

A

It is an essential component in the Node.js ecosystem as it provides various information sets about the runtime of a program.

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

NODE-PROCESS-ARGV

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

A
const process = require('process');
or just using process since it's global
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

NODE-PROCESS-ARGV

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

NODE-MODULE-SYSTEM

What is a JavaScript module?

A

a JavaScript file containing related code

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

NODE-MODULE-SYSTEM

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

A

exports, require, module, __filename, __dirname

ex:
(function (exports, require, module, \_\_filename, \_\_dirname) {
     // your code is here
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

NODE-MODULE-SYSTEM

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

A

setInterval, setTimeOut

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

NODE-REQUIRE

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

A

to export functions to another node.js module

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

NODE-REQUIRE

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

A

const someVariable = require(‘./someFileName’);

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

THE-EVENT-LOOP

What is the JavaScript Event Loop?

A

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.

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

THE-EVENT-LOOP

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

A

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

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

NODE-FS-READFILE

What is a directory?

A

it is a path to what people call a folder

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

NODE-FS-READFILE

What is a relative file path?

A

it is the actual file path to go from one directory to another

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

NODE-FS-READFILE

What is an absolute file path?

A

a file path from the root

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

NODE-FS-READFILE

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

NODE-FS-WRITEFILE

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

NODE-FS-WRITEFILE

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

HTTP-MESSAGES-RECAP

What is a client?

A

a device that request services

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

HTTP-MESSAGES-RECAP

What is a server?

A

something that responds to client requests

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

HTTP-MESSAGES-RECAP

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

A

GET

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

HTTP-MESSAGES-RECAP

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

A

start line (3 items)

  • http method (GET, PUT or POST)
  • URL
  • HTTP version ( HTTP/1.1)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

HTTP-MESSAGES-RECAP

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

A

protocol version, status code, status text

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

HTTP-MESSAGES-RECAP

What are HTTP headers?

A

meta data formatted as key:value pairs

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

HTTP-MESSAGES-RECAP

Is a body required for a valid HTTP message?

A

no

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

NPM-INTRO

What is NPM?

A

stands for Node Package Manager

  • largest JS database of free code, used to share and download code
  • website, CLI, and registry
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

NPM-INTRO

What is a package?

A

package.json and directory with 1 or more files in it

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

NPM-INTRO

How can you create a package.json with npm?

A

npm init –yes

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

NPM-INTRO

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

A

something that the package will need to run and

to download it use npm install on command line

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

NPM-INTRO

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

A
  • dependencies object will be updated

- adds the node list to the package

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

EXPRESS-INTRO

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

EXPRESS-INTRO

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

A

listen method

- Binds and listens for connections on the specified host and port

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

EXPRESS-HELLO-WORLD

How do you mount a middleware with an Express application?

A

use the ‘use’ method on an express object

i.e. app.use( )

56
Q

EXPRESS-HELLO-WORLD

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

A

req for request and res for respond

57
Q

EXPRESS-GET-JSON

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

A

application/json

58
Q

EXPRESS-POST-JSON

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

A

parses incoming json body and need it when parsing incoming json bodies

59
Q

EXPRESS-DELETE

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

A

tells the server if you’re getting or posting

60
Q

POSTGRES-INTRO

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a relational database management system,

mysql, SQL server by Microsoft, and Oracle by Oracle Corporation

61
Q

POSTGRES-INTRO

What are some advantages of learning a relational database?

A

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
Q

POSTGRES-INTRO

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status

63
Q

POSTGRES-DATABASE

What is a database schema?

A

a collection of related tables

64
Q

POSTGRES-DATABASE

What is a table?

A

list of rows with related attributes

65
Q

POSTGRES-DATABASE

What is a row?

A

a set of attributes (columns)

66
Q

SQL-SELECT

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

A

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
Q

SQL-SELECT

How do you retrieve specific columns from a database table?

A

SELECT “thisColumn”, “thatColumn”

FROM thisTable;

68
Q

SQL-SELECT

How do you filter rows based on some specific criteria?

A

SELECT “thisColumn”, “thatColumn”
FROM thisTable
WHERE “thisColumn” > 1;

69
Q

SQL-SELECT

What are the benefits of formatting your SQL?

A

looks cleaner and easier to read

70
Q

SQL-SELECT

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

A

<, >, =, !=

71
Q

SQL-SELECT

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

A

at the very bottom LIMIT clause;

SELECT “thisColumn”, “thatColumn”
FROM thisTable
WHERE “thisColumn” > 1
LIMIT 5;

72
Q

SQL-SELECT

How do you retrieve all columns from a database table?

A

SELECT *

FROM thisTable;

73
Q

SQL-SELECT

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

A

order by clause

can use desc or ascending is default

74
Q

SQL-INSERT

How do you add a row to a SQL table?

A

insert into “table” (“col1”, “col2”)

values (‘hello’, ‘world’);

75
Q

SQL-INSERT

What is a tuple?

A

a list of values

76
Q

SQL-INSERT

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

A

insert into “table” (“col1”, “col2”)
values (‘hello’, ‘world’),
(‘something’, ‘else’);

77
Q

SQL-INSERT

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

A

insert into “table” (“col1”, “col2”)
values (‘hello’, ‘world’),
(‘something’, ‘else’)
returning *; <— the returning clause with * to return all.

78
Q

SQL-UPDATE

How do you update rows in a database table?

A

update “thisTable”
set “name” = ‘something’
where “name” = ‘else’;

79
Q

SQL-UPDATE

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

A

so you dont accidentally chage the entire column

80
Q

SQL-DELETE

How do you delete rows from a database table?

A

delete from “table”
where “name” = ‘something’
returning *; <– returning clause is optional

81
Q

SQL-DELETE

How do you accidentally delete all rows from a table?

A

delete from “table”;

82
Q

SQL-JOIN

What is a foreign key?

A

a foreign key is a column used in another table to link them

83
Q

SQL-JOIN

How do you join two SQL tables?

A

use the join clause

select *
from “thisTable”
join “thisOtherTable” using (“thisColumn”);

84
Q

SQL-JOIN

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

A

use alias, can use them for more than just select statements

select “firstName” as “first”
from “thisTable” as “table”
join “otherTable” as “other”;

85
Q

SQL-AGGREGATES

What are some examples of aggregate functions?

A

MIN, MAX, SUM

86
Q

SQL-AGGREGATES

What is the purpose of a group by clause?

A

to group data that has unique values

87
Q

ES6-PROMISES

What are the three states a Promise can be in?

A

pending, fulfiled or rejected

88
Q

ES6-PROMISES

How do you handle the fulfillment of a Promise?

A

promise.then and pass a callback function

89
Q

ES6-PROMISES

How do you handle the rejection of a Promise?

A

promise.catch and pass a callback function

90
Q

ARRAY-FILTER

What is Array.prototype.filter useful for?

A

Creating a new array while excluding some elements.

91
Q

ARRAY-MAP

What is Array.prototype.map useful for?

A

Creating a new array containing the transformed elements of another.

92
Q

ARRAY-REDUCE

What is Array.prototype.reduce useful for?

A

Combining the elements of an array into a single value.

93
Q

ES6-CLASSES

What is “syntactic sugar”?

A

syntax that is designed to make things easier to read or to express.

94
Q

ES6-CLASSES

What is the typeof an ES6 class?

A

functions

95
Q

ES6-CLASSES

Describe ES6 class syntax.

A
class someName {
     constructor (var1, var2, var3) {
          this.var1 = var1;
          this.var2 = var2;
          this.var3 = var3;
     }
 someFunction() {

 } }
96
Q

ES6-CLASSES

What is “refactoring”?

A

restructuring code without changing the purpose of the original code

97
Q

WEBPACK-INTRO

What is Webpack?

A

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
Q

WEBPACK-INTRO

How do you add a devDependency to a package?

A

use –save-dev in the command line

ex: npm install –save-dev webpack

99
Q

WEBPACK-INTRO

What is an NPM script?

A

way to bundle common shell commands for your project

100
Q

WEBPACK-INTRO

How do you execute Webpack with npm run?

A

npm run build

101
Q

ES6-MODULES

How are ES Modules different from CommonJS modules?

A

ES Module = standard for JS
ex: import, export
CommonJS = default for Node.js
ex: require

102
Q

ES6-MODULES

What kind of modules can Webpack support?

A

ECMAScript, CommonJS, and AMD module

103
Q

REACT-ELEMENTS

What is React?

A

a library for building UIs. React makes it easy to create interactive UIs.

104
Q

REACT-ELEMENTS

What is a React element?

A

a react element is what gets returned from components

a plain js object.

105
Q

REACT-ELEMENTS

How do you mount a React element to the DOM?

A
const root = ReactDOM.createRoot(container);
root.render(div);
106
Q

BABEL-INTRO

What is Babel?

A

it is a compiler that transforms es6 JS to es5 JS to make it backwards compatible

106
Q

BABEL-INTRO

What is a Plug-in?

A

it is a software addon that enhances the program

107
Q

BABEL-INTRO

What is a Webpack loader?

A

allow you to pre-process files as you import or “load” them

108
Q

BABEL-INTRO

How can you make Babel and Webpack work together?

A

use npm i –save-dev babel-loader

babel compiles the code and webpack runs the code

109
Q

REACT-JSX

What is JSX?

A

syntax extension to JavaScript that produces react “elements”, structures UI similar to html

110
Q

REACT-JSX

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

A

because internally every JSX is creating a React Component using JSX transformer

111
Q

REACT-JSX

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

A

npm i –save-dev webpack
npm i –save-dev babel-loader
npm i –save-dev @babel/plugin-transform-react-jsx

112
Q

REACT-FUNCTION-COMPONENTS

What is a React component?

A

it is a function or a class whose job is to return react elements

113
Q

REACT-FUNCTION-COMPONENTS

How do you define a function component in React?

A

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
Q

REACT-FUNCTION-COMPONENTS

How do you mount a component to the DOM?

A
const container = document.querySelector('#root');
const root = ReactDOM.createRoot(container);

root.render(<.CustomButton />);

115
Q

REACT-PROPS-AND-EXPRESSIONS

What are props in React?

A

Props (properties) are arguments passed into React components through HTML attributes

116
Q

REACT-PROPS-AND-EXPRESSIONS

How do you pass props to a component?

A

by typing it with the react component

ex:
function CustomButton(props) {
  console.log(props.name)
  return {props.text};
}

<.CustomButton text=”something” name=”andy” />

117
Q

REACT-PROPS-AND-EXPRESSIONS

How do you write JavaScript expressions in JSX?

A

within curly braces { }

curly braces are how we escape JSX syntax into JS syntax

118
Q

REACT-CLASS-COMPONENTS

How do you create “class” component in React?

A
class Something extends React.Component {
    render(props) {
       return <.button> { props.text } <./button>
    }
}
119
Q

REACT-CLASS-COMPONENTS

How do you access props in a class component?

A

???

120
Q

REACT-EVENTS-AND-STATE

What is the purpose of state in React?

A

to store information or data of react components

121
Q

REACT-EVENTS-AND-STATE

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

A

pass as props (camelCase)
pass the function

ex:
<.button onClick={this.function}><./button>

122
Q

REACT-FORM-CONTROLS

What are controlled components?

A
123
Q

REACT-FORM-CONTROLS

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

A
124
Q

REACT-RENDERING-LISTS

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

A

map method

125
Q

REACT-RENDERING-LISTS

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

A
126
Q

EXPRESS-STATIC

What does express.static() return?

A

returns an object

127
Q

EXPRESS-STATIC

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

A

tells you the absolute path of the directory containing the currently file

128
Q

EXPRESS-STATIC

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

A

join combines directories into an absolute file path

129
Q

FETCH

What does fetch() return?

A

fetches a resource from the network and returns a promise which is fulfilled once the response is available

129
Q

FETCH

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

A

a get request

130
Q

FETCH

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

A

as the second optional parameter of fetch

ex: fetch (‘someLink’, {method: post})

131
Q

FETCH-IN-REACT

When does React call a component’s componentDidMount method?

A

immediately after a component is mounted (inserted into the dom tree)

132
Q

FETCH-IN-REACT

Name three React.Component lifecycle methods.

A

componentsDidMount( ),
componentsDidUpdate( ),
componentWillUnmount( )

133
Q

FETCH-IN-REACT

How do you pass data to a child component?

A

by using props to pass data