Module 1 Flashcards

1
Q

Give five examples of HTML element tags.

A

<p>, <img></img>, </p>

,<span> ,</span>, h1, h2

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

What is the purpose of HTML attributes?

A

allow you to add functionality to an HTML element

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

Give an example of an HTML entity (escape character).

A

Copyright symbol (©)

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

Where do you put visible content about the HTML document?

A

inside of the body element

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

Where do the body and head tags go in a valid HTML document?

A

inside of the main html element

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

Where do you put non-visible content about the HTML document?

A

head element

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

What is the purpose of the DOCTYPE element

A

to declare the version of HTML that the webpage uses

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

How do block-level elements affect the document flow?

A

they are shown on a new line; can add individual CSS styling using CLASS or ID attributes

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

How do inline elements affect the document flow?

A

are shown on the same line as elements before or after; can add CSS styling

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

What are the default width and height of a block-level element?

A

width: 100% of the parent element
height: height of content

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

What are the default width and height of an inline element?

A

only take as much space as needed (even if you set height and width attributes)

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

What is the difference between an ordered list and an unordered list in HTML?

A

ordered lists = numbered

unordered = bullet points

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

Is an HTML list a block element or an inline element?

A

block

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

What HTML tag is used to link to another website?

A

anchor (a) tag (usually w/ href attribute)

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

What is an absolute URL?

A

URL that referneces a different website

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

What is a relative URL?

A

URL of another page of same website

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

How do you indicate the relative link to a parent directory?

A

two dots and a forward-slash (../)

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

How do you indicate the relative link to a child directory?

A

a forward-slash and the name of the directory (/__CHILD NAME__)

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

How do you indicate the relative link to a grand parent directory?

A

two dots, back-slash, two dots, forward-slash (../../_file name__)

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

How do you indicate the relative link to the same directory?

A

just the file name or a dot and forward-slash (./)

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

What is the purpose of an HTML form element?

A

to allow the user to enter data and the webpage to collect that data

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

Give five examples of form control elements.

A

text, textarea, radio buttons, checkbox, select (dropdown list), submit button, file upload

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

Give three examples of “type” attributes for HTML input elements

A

“radio” (radio buttons), “text” (simple text), “submit” (submit button), “checkbox” (check box), “file” (upload a file), “hidden” (adds functionality to other element w/out alerting user), “password”, “email”

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

Is an HTML input element a block element or an inline element?

A

inline

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

What are the six primary HTML elements for creating tables?

A
"table"
"tr"
"td"
"th"
"tbody"
"thead"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What purpose do the “thead” and “tbody” elements serve?

A

they distinguish the content of the table from one another for screen reading and styling; divide table and give some info about what is in the divisions

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

Give two examples of data that would lend itself well to being displayed in a table.

A

financial report, sports statistics

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

What are the names of the individual pieces of a CSS rule?

A

selector and declaration block

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

In CSS, how do you select elements by their class attribute?

A

CSS: . __classname__{ }
HTML: include “class = ___” attribute in the opening tag of the element

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

In CSS, how do you select elements by their type?

A

list the element type as the selector

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

In CSS, how do you select an element by its id attribute?

A

CSS: # __idname__ { }
HTML: include “id = ___” attribute in the opening tag of the element

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

Name three different types of values you can use to specify colors in CSS.

A

RGB, hexcode and color name

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

What CSS properties make up the box model?

A

Margin, border, padding, content

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

Which CSS property pushes boxes away from each other?

A

margin

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

Which CSS property pushes box content away from its border?

A

padding

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

What is a pseudo-class?

A

keyword added to a selector that specifies a special state of the selected element(s); use ‘ : ‘ to specify pseudo-class

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

What are CSS pseudo-classes useful for?

A

making pages more interactive

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

What CSS properties make up the box model?

A

margin, border, padding

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

Which CSS property pushes boxes away from each other?

A

margin

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

Which CSS property add space between a box’s content and its border?

A

padding

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

Name at least two units of type size in CSS.

A

pixel, percentage, em

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

What CSS property controls the font used for the text inside an element?

A

“font-family”

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

What is the default flex direction of a flex container

A

row

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

What is the default flex wrap of a flex container

A

no wrap

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

Why do two div elements “vertically stack” on one another by default?

A

they are block level elements (block level elements take up 100% of the width of the parent element)

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

What is the default flex-direction of an element with display : flex?

A

row (L to R)

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

What is the default value for the position property of HTML elements?

A

static

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

How does setting position: relative on an element affect document flow?

A

it doesn’t; the element stays in the doc flow

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

How does setting position:relative on an element affect where it appears on the page?

A

it doesnt; but you can move the element in relation to where it would be in it’s fixed position using the 4 box offset properties

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

How does setting position:absolute on an element affect document flow?

A

it takes the element out of the normal doc flow; other elements will respond to the space the element takes up

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

How does setting position:absolute on an element affect where it appears on the page?

A

it appears above the parent element

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

How do you constrain an absolutely positioned element to a containing block?

A

put absolutely positioned element inside a div element w/ position set to

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

What are the four box offset properties?

A

top, bottom, left, right

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

What is the purpose of variables?

A

to hold data for future use

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

How do you declare a variable?

A

using var __var name__ = __value__; using the var keyword

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

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

A

using = (assignment operator)

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

What characters are allowed in variable names?

A

LETTERS, $, _; cant begin w/ a number

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

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

A

there is a difference between a capital and lowercase letter in the variable names

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

What is the purpose of a string?

A

to hold text content

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

What is the purpose of a number?

A

to hold numerical characters; allow for mathematical calcs

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

What is the purpose of a boolean?

A

to hold logical values (true and false)

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

What does the = operator mean in JavaScript?

A

assignment operator; assigns a value to something

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

How do you update the value of a variable?

A

__name of var__ = __new value__

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

What is the difference between null and undefined?

A

null is an intentionally invalid/nonexistent value; undefined is a value that does not exist

null = empty parking lot (created to be empty); undefined = open field (empty by its nature)

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

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

A

for readability, clarity, and debugging

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

Give five examples of JavaScript primitives.

A

numbers, strings, boolean, null and undefined

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

What data type is returned by an arithmetic operation?

A

numeric

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

What is string concatenation?

A

the combining of >=two strings to make one string

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

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

A

addition, concatenation

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

What data type is returned by comparing two values (, ===, etc)?

A

Boolean

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

What does the += “plus-equals” operator do?

A

it increments/concatenates and reassigns the new value to the original variable

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

What are objects used for?

A

to store information in key:value pairs; used to model real world data

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

What are object properties?

A

they are the keys of the key:value pairs inside an object

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

Describe object literal notation.

A

declaring the object name using the ‘var’ keyword and { }

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

How do you remove a property from an object?

A

the ‘delete’ keyword

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

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

A

dot notation: __obj name__ . __key name__ = __value___

bracket notation: __obj name__ [ __key name__] = __value___

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

What are arrays used for?

A

storing a list of related values

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

Describe array literal notation.

A

declare a variable –> assign variable a set of values contained in [ ] and separated by commas

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

How are arrays different from “plain” objects?

A

they are indexed, they do not have key:value pairs

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

What is the length property of an array?

A

a tool to get the number of items in an array

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

How do you calculate the last index of an array?

A

__array name__ . length - 1

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

What is a function in JavaScript?

A

a way to store and reuse code that produces an output

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

Describe the parts of a function definition.

A
function \_\_functName\_\_(parameter1, ... ) {
\_\_code\_\_
return \_\_output\_\_
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
85
Q

Describe the parts of a function call.

A

__functionName__ (argument1,…)

86
Q

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

A

the code, curly braces, and return are in the definition

arguments are in function call

87
Q

What is the difference between a parameter and an argument?

A

parameter is a local variable used to create the function; an argument is a data input that helps create the output

88
Q

Why are function parameters useful?

A

because they enable the user to input data to the function

89
Q

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

A

it ends the function and outputs a result

90
Q

Why do we log things to the console?

A

for debugging purposes

91
Q

What is a method?

A

a method is a function that belongs to an object

92
Q

How is a method different from any other function?

A

it is inside of an object

93
Q

How do you remove the last element from an array?

A

.pop( ) method

94
Q

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

A

.shift( ) method

95
Q

How do you generate a random number?

A

math.random( ) method of the math object

96
Q

How do you delete an element from an array?

A

.splice(index, __# of things to delete from the index__)

97
Q

How do you append an element to an array?

A

.push( ) ; also returns length of new array

98
Q

How do you break a string up into an array?

A

.split( __what you want to split at__ ) ; breaks string into an array of sub-strings split at what’s in the ( )

99
Q

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

A

no, they return a new string ; log it to the console

100
Q

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

A

~30

101
Q

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

A

no

102
Q

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

A

many

103
Q

What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?

A

MDN

104
Q

Give 6 examples of comparison operators.

A

=== , == , != , > , >= , < , <=

105
Q

What data type do comparison expressions evaluate to?

A

boolean

106
Q

What is the purpose of an if statement?

A

to evaluate a condition and make a decision

107
Q

Is else required in order to use an if statement?

A

no

108
Q

Describe the syntax (structure) of an if statement.

A

if (__condition__) {
—-code——
}

109
Q

What are the three logical operators?

A

&&& , || , !

110
Q

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

A

using logical operators (&& , ||, !)

111
Q

What are the four components of “the Cascade”.

A

source order, inheritance, specificity and “!important”

112
Q

What does the term “source order” mean with respect to CSS?

A

where the css rule set is in the stylesheet (towards the top or bottom); towards the bottom = more powerful

113
Q

How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?

A

inheritance

114
Q

List the three selector types in order of increasing specificity.

A

type selectors, class selector, ID selector

115
Q

Why is using !important considered bad practice?

A

it makes debugging more difficult by breaking the natural order of the css cascade

116
Q

What is the purpose of a loop?

A

to repeat a block of code

117
Q

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

A

to decide if it’s appropriate to run another iteration of the code

118
Q

What does “iteration” mean in the context of loops?

A

the number of times a loop is repeated

119
Q

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

A

before every iteration of the loop runs

120
Q

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

A

at the beginning of the 1st iteration

121
Q

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

A

before every iteration

122
Q

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

A

after every iteration

123
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

124
Q

What does the ++ increment operator do?

A

increases var/number/etc by 1

125
Q

How do you iterate through the keys of an object?

A

use a for (___ in __obj_)

126
Q

Why do we log things to the console?

A

debugging and they show the data

127
Q

What is a “model”?

A

how something is represented

128
Q

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

A

the document node

129
Q

What is the word “object” referring to in the phrase Document Object Model?

A

different nodes

130
Q

What is a DOM Tree?

A

the heirarchy of the nodes

131
Q

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

A

getElementById(), querySelector()

132
Q

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

A

querySelectorAll()

133
Q

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

A

to use it more than once and save time

134
Q

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

A

console.dir

135
Q

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

A

if the script tag is at the bottom, you cannot query the dom bc they ‘do not exist’ ; need html to be run before

136
Q

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

A

input: css selector in quotes
return: first html element that has that css selector

137
Q

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

A

input: any css selector in quotes

return a NodeList

138
Q

Why do we log things to the console?

A

debugging or code checking

139
Q

What is the purpose of events and event handling?

A

to make more interactive and dynamic websites

140
Q

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

A

__

141
Q

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

A

.addEventListener

142
Q

What is a callback function?

A

a function that is a parameter of another function

143
Q

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

A

__

144
Q

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

A

the element that the event listener acts on

log the event.target to the console

145
Q

What is the difference between these two snippets of code?:

element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())

A

the 2nd fires when the page loads; the 1st operates on the click

146
Q

What is the className property of element objects?

A

the css class that is applied to the html element

147
Q

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

A

access className of element and assign it to a variable–> update variable –> reaccess node/element.className = new value

148
Q

What is the textContent property of element objects?

A

the text content of the node and its child nodes

149
Q

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

A

access text content –> use . replace() or reassign –> access node.textContent = newtext

150
Q

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

A

no

151
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

harder

152
Q

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

A

__

153
Q

What does the transform property do?

A

rotates, skews, scale, or translate an element

154
Q

Give four examples of CSS transform functions.

A
rotate
translate
matrix
skew
scale
155
Q

The transition property is shorthand for which four CSS properties?

A

transition property, trans. duration, easing, delay

156
Q

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

A

focus

157
Q

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

A

blur

158
Q

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

A

input

159
Q

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

A

submit

160
Q

What does the event.preventDefault() method do?

A

stops the default action of an event from happening

161
Q

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

A

updates the url of the page as the user enters info; causes page to reload

162
Q

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

A

the elements object (document.forms. ___ . elements)

163
Q

What property of a form control object gets and sets its value?

A

doc… forms…___..ele___.value

164
Q

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

A

having to backtrack thru multiple loops to debug

165
Q

What is an advantage of having your console open when writing a JavaScript program?

A

you can see the JS console logs while you are working with before/after you work with them; you can see errors as you go

166
Q

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

A

no

167
Q

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

A

__parent node__.appendChild(__newNode__)

168
Q

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

A

the name of the attribute in “” and the value of the attribute in “”

169
Q

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

A

1) create element using: .createElement() or. createTextNode()
2) query DOM for parent node
3) use __parent__.appendChild(__neeElm__)

170
Q

What is the textContent property of an element object for?

A

to view/set the text content

171
Q

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

A

setAttribute(__att__, __value__); __elm__.className =

172
Q

What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?

A

more dynamic

can reuse the code

173
Q

Give two examples of media features that you can query in an @media rule.

A

width and height

174
Q

Which HTML meta tag is used in mobile-responsive web pages?

A

meta name= “viewport”

175
Q

What is the event.target?

A

the target of the event listener

176
Q

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

A

event bubbling

177
Q

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

A

event.type

178
Q

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

A

argument = css selector

return = the nearest ancestor element

179
Q

How can you remove an element from the DOM?

A

__elm__.remove()

180
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

add it to the parent elm (event bubbling will activate)

181
Q

What is the event.target?

A

the element that an event occurred on

182
Q

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

A

it is hidden and does not take up space (visabilty: none element still takes up space on page)

183
Q

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

A

it takes a ‘test’ and returns a boolean

184
Q

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

A

the .getAttribute() method

185
Q

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

A

the output of a loop, after a query

186
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

create eventListeners for each individual tab

187
Q

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

A

use a large if/else if statement

188
Q

What is a breakpoint in responsive Web design?

A

breakpoint is a width/height at which a media query is used to resize elements on a page

189
Q

What is the advantage of using a percentage (e.g. 50%) width instead of a fixed (e.g. px) width for a “column” class in a responsive layout?

A

so that it responds better on different screen sizes

190
Q

If you introduce CSS rules for a smaller min-width after the styles for a larger min-width in your style sheet, the CSS rules for the smaller min-width will “win”. Why is that?

A

__

191
Q

What is JSON?

A

JSON is a way to represent JS data as strings to send over networks

192
Q

What are serialization and deserialization?

A
serialization = JS --> bytes to send/save
deserialization = opposite
193
Q

Why are serialization and deserialization useful?

A

it allows us to send JS data remotely and save JS data

194
Q

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

A

use JSON.stringify()

195
Q

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

A

use JSON.parse()

196
Q

How to you store data in localStorage?

A

localStorage.setItem(“__key__”,”__val__”)

197
Q

How to you retrieve data from localStorage?

A

localStorage.getItem(“__key__”)

198
Q

What data type can localStorage save in the browser?

A

JSON strings

199
Q

When does the ‘beforeunload’ event fire on the window object?

A

before the window is unloaded (closed)

200
Q

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

A

a code block is code that is between curly braces (ex: JS object, Css rule set)

201
Q

What does block scope mean?

A

only applies to one block of code, if it is referenced outside of the block, it will be a different value/not recognized

202
Q

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

A

block-scoped

203
Q

What is the difference between let and const?

A

const = immutable; let = mutable

204
Q

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

A

you are not reassigning the ‘pointer’/address, you are modifying the object; the array is mutable, but the variable name is not

205
Q

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

A

if you need to change the variable or not (use const for array and objs; use let for ); USE CONST FOR EVERYTHING….UNTILL YOU CANT

206
Q

What is destructuring, conceptually?

A

storing values from object properties (w/o accessing the object

207
Q

What is the syntax for Object destructuring?

A

let {
__property name__,
__propertyname2__,….
} = __obj name__

208
Q

What is the syntax for Array destructuring?

A

let [__variable1__ , __variable2__, ….] = __array name__

209
Q

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

A

where the obj/array name is before/after the code block

210
Q

What is the syntax for writing a template literal?

A

__

211
Q

What is “string interpolation”?

A

__