Javascript Flashcards

1
Q

What is the purpose of variables?

A

To hold values

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

How do you declare a variable?

A

var (name of var)

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

How do you initialize (assign a value to) a variable?

A

var (name of var) = value

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

What characters are allowed in variable names?

A

a-z, numbers, $, _

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

What does it mean to say that variable names are “case sensitive”?

A

The casing matters when trying to use variables

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

What is the purpose of a string?

A

To hold a collection of characters

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

What is the purpose of a number?

A

To hold numerical data

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

What is the purpose of a boolean?

A

To announce if a value is true or false. Likewise, it can announce 0 for false and 1 for true

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

What does the = operator mean in javascript

A

The assignment operator

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

How do you update the value of a variable?

A

re assign the value using the the name of the variable and = to new value

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

What is the difference between null and undefined?

A

Null is an object, but undefined is a type

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

Why is it a good habit to include “labels” when you log values to the browser console?

A

To identify what is being printed to the console.

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

Give 5 examples of JavaScript primitives

A

string, number, boolean, null, undefined

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

What data type is returned by an arithmetic operation?

A

number

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

What is string concatenation?

A

2 strings combine and become 1 string

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

What purpose(s) does the + plus operator serve in Javascript?

A

Increment by 1

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

What data type is returned by comparing two values?

A

boolean

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

What does the += operator do?

A

Combines the left with the right

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

What are objects used for?

A

A collection of data

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

What are object properties?

A

data fields of an object

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

Describe object literal notation.

A

When you declare the object’s properties literally

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

How do you remove a property from an object?

A

Delete

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

What are the two ways to get or update the value of a property?

A

dot notation or bracket notation

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

What are arrays used for?

A

Collection of data

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

Describe array literal notation

A

create an array and place items within the indexes of the array

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

How are arrays different from “plain” objects?

A

objects do not require uniqueness

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

What number represents the first index of an array?

A

0

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

What is the length property of an array?

A

Tells how many elements are in an array

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

How do you calculate the last index of an array?

A

length -1

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

What is a function in JavaScript?

A

A set of statements that performs a task

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

Describe the parts of a function definition

A

function keyword, “name”, parameters within parenthesis, curly braces

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

Describe parts of a function call

A

function name, arguements

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

WHen comparing them side-by-side, what are the differences between a function call and function definition

A

the call only requires the name of the function and the possible arguments, the definition requires the keyword and the steps.

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

What is the difference between a parameter and an argument

A

parameter is what the function requires, but an argument is what the user passes to be used in the function

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

what two effects does a return statement have on the behavior of a function?

A

Exits the function and returns the value to the original call.

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

Why do we log things to the console?

A

To debug and check data

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

What is a method?

A

A function within a class

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

How is a method different from any other function?

A

It must be called using an object

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

How do you remove the last element of an array?

A

pop()

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

How do you round a number down to the nearest integer?

A

floor

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

How do you generate a random number?

A

random

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

How do you delete an element from an array?

A

splice

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

How do you append an element to an array?

A

push

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

How do you break a string up into an array?

A

split

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

Do string methods change the original string? How would you check if you weren’t sure?

A

No they replace it. You would log the string

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

Roughly how many string methods are there according to the MDN web docs?

A

25

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

Is the return value of a function or method useful in every situation?

A

No

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

Roughly how many array methods are there according to the MDN web docs?

A

30

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

What three-letter acronym should you always include in your google search about a javascript method or css property?

A

MDN

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

Give 6 examples of comparison operators

A

> , =, !==

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

What data type do comparison expressions evaluate to?

A

boolean

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

What is the purpose of an if statement?

A

To evaluate different conditions

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

Is else required in order to use an if statement?

A

No

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

Describe the syntax(structure) of an if statement.

A

keyword if, condition, block

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

What are the three logical operators?

A

AND, OR, NOT

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

How do you compare two different expressions in the same condition?

A

&& or ||

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

What is the purpose of a loop?

A

To repeat lines of codes

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

What is the purpose of a condition expression in a loop?

A

To let it know when to exit the loop

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

What does iteration mean in the context of loops?

A

Incrementing a counter. So each repeated step

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

When does the condition expression of a while loop get evaluated?

A

At the beginning

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

When does the initialization of a for loop get evaluated?

A

At the beginning

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

When does the condition expression of a for loop get evaluated?

A

after the initialization and after increment

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

When does the final expression of a for loop get evaluated?

A

At the end of the code block

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

Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?

A

break;

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

what does ++ increment operator do?

A

Increments the variable in use, but depending on if its in the front or back it will be used first then incremented or incremented then used

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

How do you iterate through the keys of an object?

A

for in

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

Why do we log things to the console?

A

Debugging and to find the results of data

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

What is a model?

A

The outline of an object

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

Which document is being referred to in the phrase Document Object Model

A

The HTML

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

What is the word object referring to in the phrase DOM

A

The elements in the html

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

What is a DOM tree?

A

tags

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

Give two examples of document methods that retrieve a single element from the dom.

A

querySelector, getElementByID

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

Give one example of a document method that retrieves multiple elements from the DOM at once.

A

querySelectorAll

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

Why might you want to assign the return value of a DOM query to a variable?

A

To retain that information

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

What console method allows you to inspect the properties of a DOM element object?

A

console.dir()

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

Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?

A

The element would not be created at the time the script is ran. So it would not affect the HTML

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

What does querySelector() take as its argument and what does it return?

A

Object, element

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

What does document.QuerySelectorAll() take as its argument and what does it return?

A

object, nodeList

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

Why do we log things to the console?

A

To read about the object and debug

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

What is the purpose of the events and event handling?

A

Event is what occurs when the user interacts with the page and event handling is processing what to do when that event occurs

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

What do the [] square brackets mean in function and method syntax documentation?

A

optional arguments

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

What method of element objects lets you set up a function to be called when a specific type of event occurs?

A

eventlistener

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

What is a callback function?

A

function that is meant to be passed as part of another function’s argument

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

What object is passed into an event listener callback when the event fires?

A

event

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

What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?

A

element being targeted. html, console

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

What is the difference between adding () to callback functions in addEventListener?

A

When you use () the function is called, but it is not waiting for an event to fire. We pass the name in the function rather than the function itself. Trigger when the click happens, not when the event is made

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

What is the className property of element objects?

A

Allows you to change the class attribute of an element

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

How do you update the CSS class attribute of an element using JavaScript?

A

className

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

What is the textContent property of element objects?

A

Allows you to change the textContent attribute

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

How do you update the text within an element using JavaScript?

A

Update the textContent property.

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

Is the event parameter of an event listener callback always useful?

A

no

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

Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?

A

no

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

Why is storing information about a program in variables better than only storing it in the DOM?

A

tracking, don’t want to store in the DOM

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

What event is fired when a user places their cursor in a form control?

A

focus

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

What even is fired when a user’s cursor leaves a form control?

A

blur

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

What event is fired as a user changes the value of a form control?

A

input

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

What event is fired when a user clicks the submit button within a form?

A

the data in the form is passed

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

What does the event.preventDefault() method do?

A

Cancels an event

99
Q

What does submitting a form without event.preventDefault() do?

A

Submits the form and resets

100
Q

What property of a form element object contains all of the form’s controls?

A

elements

101
Q

What property of form control object gets and sets its value

A

value

102
Q

What is one risk of writing a lot of code without checking to see if it works so far?

A

debugging will be a pain

103
Q

What is an advantage of having your console open when writing a JS program/

A

Can see errors as you got and it tells you what lines.

104
Q

Does the document.createElement() method insert a new element into the page?

A

no

105
Q

How do you add an element as a child to another element?

A

appendChild

106
Q

What do you pass as the arguments to the element.setAttribute() method?

A

attribute name, value

107
Q

What steps do you need to take in order to insert a new element into the page?

A

append it to an element that is on the html

108
Q

What is the textContent property of an element object for?

A

text content, text the user can see

109
Q

Name 2 ways to set the class attribute of a DOM element.

A

setAttribute, classList, className

110
Q

What are two advantages of defining a function to do create something?

A

Can repeatedly create an object without having to explicitly write it. So if you have a list of data, then you can just write a for loop

111
Q

The transition property is shorthand for which 4 CSS properties?

A

delay, duration, property, timing-function

112
Q

What is the event.target?

A

The element that the event was triggered on

113
Q

Why is it possible to listen for events on one element that actually happen its descendent elements?

A

Event delegation

114
Q

What DOM element property tells you what type of element it is?

A

target.tagName

115
Q

What does the element.closest() method take as its argument and what does it return?

A

string (DOMString) and it returns an element obj which is the closest ancestor of the selected element

116
Q

How can you remove an element from the DOM?

A

element.remove()

117
Q

If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?

A

put it in a div

118
Q

what is the event-target?

A

element that the event was triggered on?

119
Q

What is the affect of setting an element to display: none?

A

Removes the display

120
Q

What does the element.matches() method take as an argument and what does it return?

A

selector, returns a boolean

121
Q

How can you retrieve the value of an element’s attribute?

A

getAttribute()

122
Q

At what steps of the solution would it be helpful to log things to the console?

A

All

123
Q

If you were to add another tab and view to your HTML, but you didn’t use event delegation, how would your javascript code be written instead?

A

multiple event listeners

124
Q

If you didn’t use a loop to conditionally show or hide the views in the page, how would your javascript code b written instead?

A

many many lines

125
Q

What is JSON?

A

Javascript object notation

126
Q

What are serialization and deserialization?

A

Serialization - Converting objects into byte stream

Deserialization - Turning byte stream into objects

127
Q

Why are serialization and deserialization useful?

A

Allows us to send data

128
Q

How do you serialize a data structure into a JSON string using JavaScript?

A

.stringify()

129
Q

How do you deserialize a JSON string into a data structure using javascript?

A

.parse()

130
Q

How do you store data in localstorage?

A

localstorage.setItem()

131
Q

How do you retrieve data from localstorage?

A

getItem()

132
Q

What data type can localStorage save in the browser?

A

string

133
Q

When does the beforeUnload event first on the window object?

A

right before closing the window

134
Q

What is a method?

A

a function which is a property of an object

135
Q

How can you tell the difference between a method definition and a method call?

A

A method definition goes within the object and takes parameters. Method call will call the object and send arguments

136
Q

Describe method definition syntax(structure).

A

function name, parameters, definition;

137
Q

Describe method call syntax(structure).

A

obj, method name, arguements;

138
Q

How is method different from any other function?

A

Methods belong to objects so they can manipulate the object and its properties

139
Q

What is the defining characteristic of OOP?

A

The use of objects to hold properties

140
Q

What are the four principles of OOP?

A

Abstraction, encapsulation, inheritance, polymorphism

141
Q

What is abstraction?

A

Hiding functionality from users. ie interfaces

142
Q

What does API stand for?

A

Application Programmign Interface

143
Q

What is the purpose of an API

A

Defines interactions between multiple software intermediaries

144
Q

What is this in JavaScript?

A

refer to the object that it currently is referring to

145
Q

What does it mean to say that this is an implicit parameter?

A

does not need to be specified

146
Q

When is the value of this determined in a function; call time or definition time?

A

call time

147
Q

How can you tell what the value of this will be for a particular function or method definition?

A

The object from where its being referred

148
Q

How can you tell what the value of this is for a particular function or method call?

A

The object that calls the function

149
Q

What kind of inheritance does the javascript language use?

A

Prototypal inheritance

150
Q

What is a prototype in javascript?

A

template object

151
Q

How is it possible to call methods on strings, arrays, and numbers even though those methods dont actually exist on objects, arrays, and numbers?

A

proto

152
Q

If an object does not have its own property or method by a given key, where does javascript look for it?

A

proto

153
Q

What does the new operator do?

A

Creates a new instance of an object

154
Q

What property of JavaScript functions can store shared behavior for instances created with new?

A

prototype

155
Q

What does the instanceof operator do?

A

Check if the object is inheriting from the specified object

156
Q

What is a callback function?

A

A function passed into another function as an argument

157
Q

Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?

A

setTimeOut()

158
Q

How can you set up a function to be called repeatedly without using a loop?

A

interval

159
Q

What is the default time delay if you omit the delay parameter from setTimeOut or setInterval()?

A

0

160
Q

What do setTimeout() and setInterval() return?

A

timeoutID

161
Q

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

A

Its code that is grouped together that can be executed within its scope. functions, for statements, if statements

162
Q

What does block scope mean?

A

Variables that are declared within a block only exist within that block

163
Q

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

A

The block

164
Q

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

A

const are not immutable. The variable itself is read only, but you may manipulate the contents inside. You just cannot instantiate the variable

165
Q

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

A

const for all things

let if you can’t const.

166
Q

What is destructuring, conceptually?

A

Decompose the properties of an object or the indexes of an array to separate them to create specific variables

167
Q

What is the syntax for object destructuring?

A

let {object: name} = “object to get from”

168
Q

What is the syntax for Array destructuring?

A

let {object} = “array to get from”

169
Q

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

A

If the declaration of the variable is on the left or right side.

170
Q

What is the syntax for writing a template literal?

A

` ${variable}`

171
Q

What is “string interpolation”?

A

Replace placeholders with values in a string literal

172
Q

What is the syntax for defining an arrow function?

A

() => {}

173
Q

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

A

its a 1 liner

174
Q

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

A

it is determined by the surrounding scope

175
Q

What is a CLI?

A

Command line interface

176
Q

What is a GUI?

A

Graphical User Interface

177
Q

man

A

man cat

178
Q

cat

A

cat txt file

179
Q

ls

A

ls any directory

180
Q

pwd

A

pwd to find your directory

181
Q

echo

A

to write arguments

182
Q

touch

A

Create a file

183
Q

mkdir

A

Create directory

184
Q

mv

A

Move

185
Q

rm

A

Remove

186
Q

cp

A

copy

187
Q

What are the three virtues of a great programmer?

A

lazy, patience, huburous

188
Q

What is Node.js?

A

Server environment

189
Q

What can Node.js be used for?

A

Single-threaded, non-blocking, asynchronously programming, generate dynamic page content, crud on server, collect form data, add, delete, modify data in db

190
Q

What is REPL?

A

Read-Eval-Print-Loop,

Shell that processes node expressions

191
Q

When was Node.js created?

A

2009

192
Q

What back end languages have you heard of?

A

java, .net, python, ruby, php, go

193
Q

What is a process?

A

Computer program that is being executed on 1 or more threads

194
Q

Roughly how many computer processes are running on your host operating system?

A

151

195
Q

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

A

Application speed, memory needed, optimization, bottlenecks

196
Q

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

A

Global object that provides information about the current Node.js process

197
Q

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

A

process object and node command

198
Q

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

A

Array

199
Q

What is a javascript module?

A

Exports specific objects making them available

200
Q

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

A

exports, require, module, __filename, __dirname

201
Q

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

A

global process

202
Q

What is Array.prototype.filter useful for?

A

You can filter out unwanted or wanted data.

203
Q

What is Array.prototype.map useful for?

A

When you want to manipulate values within an array

204
Q

What is Array.prototype.reduce useful for?

A

To reduce to 1 obj

205
Q

What is syntactic sugar?

A

Syntax to make things more readable

206
Q

What is the typeof an ES6 class?

A

function

207
Q

Describe ES6 class syntax.

A

class {
constructor(){}
methods()
}

208
Q

What is refactoring?

A

restructure code to be more legible, or improve design, WITHOUT changing its functionality

209
Q

How are ES modules different from CommonJS modules?

A

ES6 is pre-parsed

CommonJS load dependencies on demand

210
Q

What is React?

A

A front-end javascript library

211
Q

What is a React element?

A

JSX, object like a DOM node

212
Q

How do you mount a React element to the DOM?

A

ReactDOM.render

213
Q

What is Babel?

A

Toolchain made to convert ES6 to ES5

214
Q

What is a Plug-in?

A

Component that adds a feature

215
Q

What is a Webpack loader?

A

transformations that are applied to the sources code of a module

216
Q

How can you make Babel and Webpack work together?

A

babel-loader

217
Q

What is JSX?

A

Syntax extension

218
Q

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

A

JSX compiles into calls to React.createElement()

219
Q

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

A

plugin-transform-react-jsx

220
Q

What are props in react?

A

Dynamic data. Properties to add into your component

221
Q

How do you pass props to a component?

A

Add it as a parameter, then user {props.name}

222
Q

How do you write JavaScript expressions in JSX?

A

{}

223
Q

How do you create “class” component in React?

A

extends React.Component

224
Q

How do you access props in a class component?

A

this.props

225
Q

What is the purpose of state in React?

A

to have different dynamic data

226
Q

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

A

bind this, attribute

227
Q

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

A

Map

228
Q

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

A

Index or ID

229
Q

What are controlled components?

A

When a components input value is driven by React state

230
Q

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

A

handleChange, handleSubmit

231
Q

What does express.static() return?

A

middleware

232
Q

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

A

directory name of the current module

233
Q

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

A

Join path segments

234
Q

What does fetch() return?

A

promise

235
Q

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

A

get

236
Q

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

A

Create a request with the necessary headers

237
Q

When does React call a component’s componentDidMount method?

A

After a component is mounted

238
Q

name 3 React.Component lifecycle methods

A

ComponentDidMount, DidUpdate, WillUnMount

239
Q

How do you pass data to a child component?

A

props

240
Q

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

A

function

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

wrap is equal to value
value is = to function that returns value.

const wrap = value

value = function () {
return value}

function that calls another function that returns the parameter

242
Q

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

A

defined

243
Q

What allows javascript functions to remember values from their surroundings?

A

Closures