Week 8 and Week 9 Quiz Questions Flashcards

1
Q

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

A

lines of code used in and denoted by curly braces {} often used in if statements, for loops, do while loops, etc

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

What does block scope mean?

A

in block scope, variables and other items/ objects are only referenced within the block itself, and thus have no effect on the global scale or other codes blocks in a function.

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

both are block level

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

const is immutable and cannot be changed– it is read-only.

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

values of const variables can change, but the const variable cannot directly be edited(array is referenced datatype and not a primitive (that cannot be changed))

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

look at scope first, then think about if variables can just be read-only and never changed vs if variable can/ needs to 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 a template literal?

A

use backticks (`) instead of quotation
variables called by using ${variableName} inside backticks

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

What is “string interpolation”?

A

substituting part of a string for the value of a variable or expression

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

What is destructuring, conceptually?

A

being able to assign component parts of arrays and objects into variables

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 {variable1, variable2} = object;
OR
const {prop1: variable1, prop2: variable2} = object;

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

const [variable1, variable2] = array;

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

brackets come first before equals sign

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

What is the syntax for defining an arrow function?

A

const variableName = (parameter1, parameter2) => {function code block}

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

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

A

return is implied. only one expression (line) is read as well

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

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

A

this is defined at definition time not call time in arrow functions.

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

this in arrow functions

A

this in arrow functions reference the relative object they are in. (as opposed to this being the window object) DIRECT PARENT

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

What is a CLI?
`

A

command line interfaces

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

What is a GUI?

A

graphical user interface

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

What are the 3 components of a fullstack Web architecture?

A

The frontend that the user interacts with (Web site or Mobile app)

The backend server that takes requests from the frontend and processes them

The database where data is stored and used across all instances of the frontend

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

What is Node.js?

A

Node.js is 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

What can Node.js be used for?

A

It is commonly used to build backends 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
22
Q

What is a REPL?

A

read-evaluate-print loop

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

What backend languages have you heard of?

A

python, java

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

What is a computer process?

A

computer process executes the passive “instructions” from a computer program– an application that is running is a process

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

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

hundreds

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

Why should a full stack Web developer know that computer processes exist?

A

to understand how their programs actually interact with a computer

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

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

A

can just log it? – can just type in ‘process’

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

How do you access the command line arguments in a Node.js program?

A

process.argv[index]

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

What is a JavaScript module?

A

In JavaScript, a “module” is a single .js file.

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

What are the advantages of modular programming?

A

easy to change/ edit individual modules/ functions

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

In JavaScript, how do you make a function in a module available to other modules?

A

use:
export { function as default }

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

In JavaScript, how do you use a function from another module?

A

use:
import function from ‘./filename.ext’

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

What is the JavaScript Event Loop?

A

pushes the first item in the code task queue to the call stack (order in which code is executed) if the call stack is empty

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

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

A

Blocking refers to operations that block further execution until that operation finishes while non-blocking (asynchronous) refers to code that doesn’t block execution

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

What are the three states a Promise can be in?

A

pending, fulfilled, rejected

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

How do you handle the fulfillment of a Promise?

A

.then()

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

How do you handle the rejection of a Promise?

A

.catch()

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

What does Array.filter do?

A

creates a shallow copy of Array if the elements in the array pass the test (truthy) that is in filter

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

What should the callback function return?

A

truthy/falsey or true/false (boolean)

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

What is Array.filter useful for?

A

when checking an array, if items are true/ false.

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

What does Array.map do?

A

returns new array of elements that are created from original array that is passed through a function

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

What should the callback function return?

A

a new result of the array at that index as the return of the function

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

What is Array.map useful for?

A

applying the same change to multiples items in an array

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

What does Array.reduce do?

A

Returns final result of running the reducer function across all elements of the array is a single value.

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

What action should the callback function perform?

A

contains an accumulator and currentValue (and initialValue sometimes)
accumulator accumulates the currentValues through the array until the end and returns the final result as a single value from the accumulator

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

What should the callback function return?

A

the value from accumulator

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

What is Array.reduce useful for?

A

gathering/ combining contents/ values of an array into one value

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

What is a directory?

A

collection of locations of files

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

What is a relative file path?

A

./fileName
shortest way to get the file you need relative to current location

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

What is an absolute file path?

A

points to absolute location of file regardless of your location

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

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

A

fs

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

What method is available in the node:fs module for reading data from a file?

A

readFile()

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

What method is available in the node:fs module for writing data to a file?

A

writeFile()

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

What is a client?

A

a ‘thing’ (software/ program) that requests a service

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

What is a server?

A

provider (software/ program) of a service, handles request from client

60
Q

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

A

GET

61
Q

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

A

HTTP method, request target, HTTP version

62
Q

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

A

protocol version (usually HTTP/1.1), status code, status text

63
Q

What are HTTP headers?

A

get additional info from requests

64
Q

Is a body required for a valid HTTP message?

A

optional

65
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 (kind of like github)

66
Q

What is a package?

A

directory with one or more files (with package.json)

67
Q

How can you create a package.json with npm?

A

npm init

68
Q

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

A

required for application/package to run - requires the dependency

69
Q

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

A
70
Q

What are some other popular package managers?

A

Yarn (facebook) and PNPM

71
Q

What is Express useful for?

A

server built for node
–simplicity and ease of use.

72
Q

How does Express fit into a full-stack web application?

A

back-end/ server

73
Q

How do you add express to your package dependencies?

A

npm install express

74
Q

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

A

app.listen(PORT_NUMBER, () => {
console.log(‘Express server listening on port 8080’);
});

75
Q

What is Express middleware?

A

callback function – middleware are functions that have access to the request object (req) and response object (res)

76
Q

What is Express middleware useful for?

A

reacting to http requests

77
Q

How do you mount a middleware with an Express application?

A

call the use() method and pass through it the middleware function

78
Q

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

A

request object, response object, next function

79
Q

What is an API endpoint?

A

place where API responds to requests

80
Q

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

A

application/JSON

81
Q

app.get() vs app.use()

A

get responds only to get requests, use responds to post, any requests

82
Q

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

A

only if it matches the request method typed in – the methods are technically arbitrary, but must match what is typed in

83
Q

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

A

express.json() parses out data from json into javascript
if any endpoints dependent on it, must be written BEFORE the endpoint
relevant to req.body – is undefined until express.json is called

84
Q

Why do we use databases in Web development?

A

databases allow applications to retrieve and store data quickly in an organized manner and can be shared by many users– persistency of data as well

85
Q

What is PostgreSQL and what are some alternative relational databases?

A

postgresql is a Relational Database Management System (RDBMS) that is free and open-source
alternative relational databases are mysql and oracle

86
Q

What are some advantages of learning a relational database?

A

relational database good for storing data that is related to each other. also supports good guarantees of data integrity and a popular type of database

87
Q

What is one way to see if PostgreSQL is running?

A

open 2 terminals and run ‘top’ in one of them.
in the other, run the command ‘sudo service postgresql start’ and top will show a postgresql process

88
Q

What is a database schema?

A

collection of tables, defines how data in relational databases should be organized

89
Q

What is a table?

A

where relational databases store data in relations

90
Q

What is a row?

A

makes up a table and all have the same attributes between each row

91
Q

What is an attribute and what other names are used to describe them?

A

columns– they are the different characteristics that are in common between each row

92
Q

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

A

structured query language
it is declarative rather than imperative– coders describe what they want in the code and thats how it is written

93
Q

How do you retrieve specific columns from a database table?

A

using :
SELECT “column”

94
Q

How do you filter rows based on some specific criteria?

A

using:
WHERE “column” = ‘value’;

95
Q

What are the benefits of formatting your SQL?

A

easier/ cleaner to read

96
Q

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

A

=, !=, >, <

97
Q

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

A

using:
LIMIT 10 (or whatever number)

98
Q

How do you retrieve all columns from a database table?

A

using:
SELECT *

99
Q

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

A

using:
order by “columnName” (DESC if wanted, default is ascending order)

100
Q

How do you add a row to a SQL table?

A

INSERT into “tableName” (prop1, prop2)
VALUES (val1, val2)
returning *;

101
Q

What is a tuple?

A

list of values in same order of column names

102
Q

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

A

in VALUES, separate each new row by a new set of parentheses and comma between each row

103
Q

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

A

returning *;

104
Q

How do you update rows in a database table?

A

UPDATE “tableName”
SET “propertyName” = ‘newValue’
WHERE “propertyName” = ‘originalName’

105
Q

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

A

if you dont, the update will apply to every row in the table

106
Q

How do you delete rows from a database table?

A

DELETE
from “tableName”
WHERE “propertyName” = ‘value’

107
Q

How do you accidentally delete all rows from a table?

A

by not including WHERE

108
Q

What is a foreign key?

A

a column that links two tables

109
Q

How do you join two SQL tables?

A

SELECT “tablename”.”columnName”
FROM “tableName”
JOIN “othertable” using (“foreign key”)

110
Q

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

A

use:
“tempName”.”columnName” as “NEWNAME”

111
Q

What are some examples of aggregate functions?

A

count(), sum(), avg(), every()

112
Q

What is the purpose of a group by clause?

A

to separate rows into their own groups

113
Q

What is Webpack?

A

Bundles javascript, compiles bunch of js files into one “main.js” file

114
Q

How do you add a devDependency to a package?

A

npm install BLAHBLAH –save-dev
just for dev work before deployment

115
Q

What is an NPM script?

A

automates commands contained in them

116
Q

How do you execute Webpack with npm run?

A

npm run build(or script)

117
Q

What is Babel?

A

javascript compiler that converts any JS above ES5 back down to ES5 (or lower)
can transform syntax among other features

118
Q

What is a Plug-in?

A

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

119
Q

What is a Webpack loader?

A

webpack loader applies transformations to code and can pre-process files before they are loaded/ imported

120
Q

How can you make Babel and Webpack work together?

A

via webpack.config.js

121
Q

What is React?

A

React is a library that lets you write JSX DOM elements
made up of components (UI with its own logic and appearance) that are made of JavaScript and return markup

122
Q

What is a React element?

A

at its simplest, a JS object

123
Q

How do you mount a React element to the DOM?

A

src > index.js is always root of react app and where app is loaded into the DOM

.createRoot(document.asldkjsad)

124
Q

What is JSX?

A

way of writing JS that LOOKS like HTML

125
Q

How does React use JSX to render components?

A

–babel–

126
Q

What is a React component?

A

they make UI elements in your app that you can reuse
always defined as functions that return JSX

127
Q

How do you define a component in React?

A

export default function ThisIsName() {codeblock}

128
Q

How do you mount a component to the DOM (or “render” a component)?

A

import the component to the index.js (the root) that takes app.js

129
Q

What are props in React?

A

Props are the information that you pass to a JSX tag. like attributes in HTML for JSX

130
Q

How do you use props in a component?

A

just do propName=’text’
propName={value}
propName={{nested object}}

131
Q

How do you pass props to a component?

A

can just do it directly, or add prop names to main React component/ function as “variables” to use inside child elements

132
Q

How do you write JavaScript expressions in JSX?

A

curly braces {}

133
Q
  1. How many parameters does the following function have?

function FooBar(props) {
const { name, rank, serialNo } = props;
// …
}

A

1

134
Q

Describe the parameter(s).

A

(props)

135
Q

How many parameters does the following function have?
function FooBar({ name, rank, serialNo }) {
// …
}

A

1? 3 props

136
Q

Describe the parameter(s).

A

1 parameter with 3 props

137
Q

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

A

passed via props

138
Q

How do you add custom event handlers to a React component?

A

add it as a property to an element

139
Q

What is the naming convention for custom event handlers?

A

handle……
handleClick

140
Q

What are some custom events a component may expose?

A
141
Q

What are hooks in React?

A

special functions only available while React is rendering, hooks into diff React features

142
Q

What are the “Rules of Hooks”? (if necessary, re-read the “Pitfall” box in State)

A

can only be called at top level of components

143
Q

What is the purpose of state in React?

A

when components need to “remember” things: the current input value, the current image, etc

144
Q

Why can’t we just maintain state in a local variable?

A

Local variables don’t persist between renders and changes to local variables won’t trigger renders

145
Q

What two actions happen when you call a state setter function?

A

updates the state variable value in a cache and triggers React to render the whole component again

146
Q

When does the local state variable get updated with the new value?

A

after the state setter function is called (After re-render)