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
What is a computer process?
computer process executes the passive "instructions" from a computer program-- an application that is running is a process
26
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
hundreds
27
Why should a full stack Web developer know that computer processes exist?
to understand how their programs actually interact with a computer
28
What is the process object in a Node.js program?
a global that provides information about, and control over, the current Node.js process
29
How do you access the process object in a Node.js program?
can just log it? -- can just type in 'process'
30
What is the data type of process.argv in Node.js?
array
31
How do you access the command line arguments in a Node.js program?
process.argv[index]
32
What is a JavaScript module?
In JavaScript, a "module" is a single .js file.
33
What are the advantages of modular programming?
easy to change/ edit individual modules/ functions
34
In JavaScript, how do you make a function in a module available to other modules?
use: export { function as default }
35
In JavaScript, how do you use a function from another module?
use: import function from './filename.ext'
36
What is the JavaScript Event Loop?
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
37
What is different between "blocking" and "non-blocking" with respect to how code is executed?
Blocking refers to operations that block further execution until that operation finishes while non-blocking (asynchronous) refers to code that doesn't block execution
38
What are the three states a Promise can be in?
pending, fulfilled, rejected
39
How do you handle the fulfillment of a Promise?
.then()
40
How do you handle the rejection of a Promise?
.catch()
41
What does Array.filter do?
creates a shallow copy of Array if the elements in the array pass the test (truthy) that is in filter
42
What should the callback function return?
truthy/falsey or true/false (boolean)
43
What is Array.filter useful for?
when checking an array, if items are true/ false.
44
What does Array.map do?
returns new array of elements that are created from original array that is passed through a function
45
What should the callback function return?
a new result of the array at that index as the return of the function
46
What is Array.map useful for?
applying the same change to multiples items in an array
47
What does Array.reduce do?
Returns final result of running the reducer function across all elements of the array is a single value.
48
What action should the callback function perform?
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
49
What should the callback function return?
the value from accumulator
50
What is Array.reduce useful for?
gathering/ combining contents/ values of an array into one value
51
What is a directory?
collection of locations of files
52
What is a relative file path?
./fileName shortest way to get the file you need relative to current location
53
What is an absolute file path?
points to absolute location of file regardless of your location
54
What module does Node.js include for manipulating the file system?
fs
55
What method is available in the node:fs module for reading data from a file?
readFile()
56
What method is available in the node:fs module for writing data to a file?
writeFile()
57
Are file operations using the fs module synchronous or asynchronous?
asynchronous
58
What is a client?
a 'thing' (software/ program) that requests a service
59
What is a server?
provider (software/ program) of a service, handles request from client
60
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
61
What is on the first line of an HTTP request message?
HTTP method, request target, HTTP version
62
What is on the first line of an HTTP response message?
protocol version (usually HTTP/1.1), status code, status text
63
What are HTTP headers?
get additional info from requests
64
Is a body required for a valid HTTP message?
optional
65
What is NPM?
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
What is a package?
directory with one or more files (with package.json)
67
How can you create a package.json with npm?
npm init
68
What is a dependency and how do you add one to a package?
required for application/package to run - requires the dependency
69
What happens when you add a dependency to a package with npm?
70
What are some other popular package managers?
Yarn (facebook) and PNPM
71
What is Express useful for?
server built for node --simplicity and ease of use.
72
How does Express fit into a full-stack web application?
back-end/ server
73
How do you add express to your package dependencies?
npm install express
74
What Express application method starts the server and binds it to a network PORT?
app.listen(PORT_NUMBER, () => { console.log('Express server listening on port 8080'); });
75
What is Express middleware?
callback function -- middleware are functions that have access to the request object (req) and response object (res)
76
What is Express middleware useful for?
reacting to http requests
77
How do you mount a middleware with an Express application?
call the use() method and pass through it the middleware function
78
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request object, response object, next function
79
What is an API endpoint?
place where API responds to requests
80
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/JSON
81
app.get() vs app.use()
get responds only to get requests, use responds to post, any requests
82
What is the significance of an HTTP request's method?
only if it matches the request method typed in -- the methods are technically arbitrary, but must match what is typed in
83
What does the express.json() middleware do and when would you need it?
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
Why do we use databases in Web development?
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
What is PostgreSQL and what are some alternative relational databases?
postgresql is a Relational Database Management System (RDBMS) that is free and open-source alternative relational databases are mysql and oracle
86
What are some advantages of learning a relational database?
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
What is one way to see if PostgreSQL is running?
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
What is a database schema?
collection of tables, defines how data in relational databases should be organized
89
What is a table?
where relational databases store data in relations
90
What is a row?
makes up a table and all have the same attributes between each row
91
What is an attribute and what other names are used to describe them?
columns-- they are the different characteristics that are in common between each row
92
What is SQL and how is it different from languages like JavaScript?
structured query language it is declarative rather than imperative-- coders describe what they want in the code and thats how it is written
93
How do you retrieve specific columns from a database table?
using : SELECT "column"
94
How do you filter rows based on some specific criteria?
using: WHERE "column" = 'value';
95
What are the benefits of formatting your SQL?
easier/ cleaner to read
96
What are four comparison operators that can be used in a where clause?
=, !=, >, <
97
How do you limit the number of rows returned in a result set?
using: LIMIT 10 (or whatever number)
98
How do you retrieve all columns from a database table?
using: SELECT *
99
How do you control the sort order of a result set?
using: order by "columnName" (DESC if wanted, default is ascending order)
100
How do you add a row to a SQL table?
INSERT into "tableName" (prop1, prop2) VALUES (val1, val2) returning *;
101
What is a tuple?
list of values in same order of column names
102
How do you add multiple rows to a SQL table at once?
in VALUES, separate each new row by a new set of parentheses and comma between each row
103
How do you get back the row being inserted into a table without a separate select statement?
returning *;
104
How do you update rows in a database table?
UPDATE "tableName" SET "propertyName" = 'newValue' WHERE "propertyName" = 'originalName'
105
Why is it important to include a where clause in your update statements?
if you dont, the update will apply to every row in the table
106
How do you delete rows from a database table?
DELETE from "tableName" WHERE "propertyName" = 'value'
107
How do you accidentally delete all rows from a table?
by not including WHERE
108
What is a foreign key?
a column that links two tables
109
How do you join two SQL tables?
SELECT "tablename"."columnName" FROM "tableName" JOIN "othertable" using ("foreign key")
110
How do you temporarily rename columns or tables in a SQL statement?
use: "tempName"."columnName" as "NEWNAME"
111
What are some examples of aggregate functions?
count(), sum(), avg(), every()
112
What is the purpose of a group by clause?
to separate rows into their own groups
113
What is Webpack?
Bundles javascript, compiles bunch of js files into one "main.js" file
114
How do you add a devDependency to a package?
npm install BLAHBLAH --save-dev just for dev work before deployment
115
What is an NPM script?
automates commands contained in them
116
How do you execute Webpack with npm run?
npm run build(or script)
117
What is Babel?
javascript compiler that converts any JS above ES5 back down to ES5 (or lower) can transform syntax among other features
118
What is a Plug-in?
a software component that adds a specific feature to an existing computer program. enables customization
119
What is a Webpack loader?
webpack loader applies transformations to code and can pre-process files before they are loaded/ imported
120
How can you make Babel and Webpack work together?
via webpack.config.js
121
What is React?
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
What is a React element?
at its simplest, a JS object
123
How do you mount a React element to the DOM?
src > index.js is always root of react app and where app is loaded into the DOM .createRoot(document.asldkjsad)
124
What is JSX?
way of writing JS that LOOKS like HTML
125
How does React use JSX to render components?
--babel--
126
What is a React component?
they make UI elements in your app that you can reuse always defined as functions that return JSX
127
How do you define a component in React?
export default function ThisIsName() {codeblock}
128
How do you mount a component to the DOM (or "render" a component)?
import the component to the index.js (the root) that takes app.js
129
What are props in React?
Props are the information that you pass to a JSX tag. like attributes in HTML for JSX
130
How do you use props in a component?
just do propName='text' propName={value} propName={{nested object}}
131
How do you pass props to a component?
can just do it directly, or add prop names to main React component/ function as "variables" to use inside child elements
132
How do you write JavaScript expressions in JSX?
curly braces {}
133
1. How many parameters does the following function have? function FooBar(props) { const { name, rank, serialNo } = props; // ... }
1
134
Describe the parameter(s).
(props)
135
How many parameters does the following function have? function FooBar({ name, rank, serialNo }) { // ... }
1? 3 props
136
Describe the parameter(s).
1 parameter with 3 props
137
How to you pass an event handler to a React component?
passed via props
138
How do you add custom event handlers to a React component?
add it as a property to an element
139
What is the naming convention for custom event handlers?
handle...... handleClick
140
What are some custom events a component may expose?
141
What are hooks in React?
special functions only available while React is rendering, hooks into diff React features
142
What are the "Rules of Hooks"? (if necessary, re-read the "Pitfall" box in State)
can only be called at top level of components
143
What is the purpose of state in React?
when components need to “remember” things: the current input value, the current image, etc
144
Why can't we just maintain state in a local variable?
Local variables don’t persist between renders and changes to local variables won’t trigger renders
145
What two actions happen when you call a state setter function?
updates the state variable value in a cache and triggers React to render the whole component again
146
When does the local state variable get updated with the new value?
after the state setter function is called (After re-render)