LFZ Flashcards

1
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
2
Q

Where do you put visible content about the HTML document?

A

body element

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

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

A

inside the html element

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

What is the purpose of a declaration?

A

to tell a browser which version of HTML the page is using

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

Give five examples of HTML element types.

A

html, head, title, body, h1, h2, h3, h4, h5, h6, p, div, span, a

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

What is the purpose of HTML attributes?

A

Attributes provide additional information about the contents of an element.

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

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

A
Less-than sign - & lt;
Greater-than sign - & gt;
Ampersand - & amp;
Quotation mark - & quot;
Cent-sign - & cent;
Pound sign - & pound;
Yen sign - & yen;
Euro sign - & euro;
Copyright symbol - & copy;
Registered trademark - & reg;
Trademark - & trade;
Left single quote - & lsquo;
Right single quote - & rsquo;
Left double quotes - & ldquo;
Right double quotes - & rdquo;
Multiplication sign - & times;
Division sign - & divide;
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

A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can).

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

An inline element does not start on a new line and only takes up as much width as necessary.

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

The default height of a block-level element is the height of the content.
The default width of a block-level element is the length of the page.

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

The height of an inline element is the height of the content.
The width of an inline element is the width of the content.

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 list displays numbered list. Unordered list displays bullet point list.

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 element

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

<a> (anchor element)</a>

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

What is an absolute URL?

A

the full web address for the site

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

What is a relative URL?

A

link to other pages within the same site

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

Use ../ to indicate the folder above the current one, then follow it with the file name.

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

For a child folder, use the name of the child folder, followed by a forward slash, then the file 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

Repeat the ../ to indicate that you want to go up two folders (rather than one), then follow it with the 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

To link to a file in the same folder, just use the file name. (Nothing else is needed.)

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

An HTML form is used to collect user input.

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
input
label
select
textarea
button
fieldset
legend
datalist
output
option
optgroup
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Give three examples of type attribute values for HTML input elements.

A

text, password, radio, checkbox, file, submit, image, hidden

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

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

A

inline element

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, th, td, thead, tbody

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

The headings of the table should sit inside the thead element.
The body should sit inside the tbody element.

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

Examples of tables include financial reports, TV schedules, and sports results.

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

Give 6 examples of comparison operators.

A

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

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

What is the purpose of an if statement?

A

to execute code if a condition evaluates to true

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

Describe the syntax (structure) of an if statement.

A
if key word
condition
opening curly brace
code to execute if value is true
closing curly brace
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What are the three logical operators?

A

&&
||
!

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

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

A

and operator

or operator

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

What is the purpose of a loop?

A

Loops are all about doing the same thing over and over again.

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

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

A

The conditionExpression expression is evaluated. If the value of conditionExpression is true, the loop statements execute. If the value of condition is false, the for loop terminates.

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

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

A

one loop

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

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

A

before a loop begins

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

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

A

it’s executed once at the beginning of the first loop

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

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

A

before each loop

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

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

A

end of the loop

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

What does the ++ increment operator do?

A

adds one

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

How do you iterate through the keys of an object?

A

for…in loop

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

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

A

selectors, declarations

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

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

A

.class-name

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

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

A

element-name

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

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

A

id-name

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

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

A

RGB values, hex codes, color names

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

What CSS properties make up the box model?

A

content, padding, border, margin

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

What is a pseudo-class?

A

A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s).

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

What are CSS pseudo-classes useful for?

A

allow you to change the appearance of elements when a user is interacting with them

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

Name two types of units that can be used to adjust font-size in CSS.

A

pixels, percentages, ems

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

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

A

div elements are block-level elements by default

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

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

A

row

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

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

A

The element is positioned according to the normal flow of the document, and then offset relative to itself based on the values of top, right, bottom, and left.

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

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

A

The offset does not affect the position of any other elements; thus, the space given for the element in the page layout is the same as if position were static.

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

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

A

The element is removed from the normal document flow

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

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

A

, and no space is created for the element in the page layout. It is positioned relative to its closest positioned ancestor, if any; otherwise, it is placed relative to the initial containing block. Its final position is determined by the values of top, right, bottom, and left.

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

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

A

containing block position should be set to relative

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

What are the four box offset properties?

A

top, bottom, right, left

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

What are the four components of “the Cascade”.

A

source order, inheritance, specificity, importantance

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

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

A

Source order is, simply put, the order that your CSS rules are written in your stylesheet.

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

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

List the three selector types in order of increasing specificity.

A

type, class, id

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

Why is using !important considered bad practice?

A

Using !important, however, is bad practice and should be avoided because it makes debugging more difficult by breaking the natural cascading in your stylesheets.

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

The transition property is shorthand for which four CSS properties?

A

transition-property, transition-duration, transition-timing-function, and transition-delay

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

What is the purpose of variables?

A

store information

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

How do you declare a variable?

A

var variable;

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

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

A

var variable = value;

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

What characters are allowed in variable names?

A

letters, numbers, dollar signs, underscore

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

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

A

variables with the same name but different cases are different variables

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

What is the purpose of a string?

A

working with text

80
Q

What is the purpose of a number?

A

counting or calculating

81
Q

What is the purpose of a boolean?

A

logic

82
Q

What does the = operator mean in JavaScript?

A

assign value

83
Q

How do you update the value of a variable?

A

declare the variable and assign new value

84
Q

What is the difference between null and undefined?

A

null is the given value of no value

undefined is no value given

85
Q

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

A

to help you debug

86
Q

Give five examples of JavaScript primitives.

A

undefined , null , boolean , string and number

87
Q

What data type is returned by an arithmetic operation?

A

number

88
Q

What is string concatenation?

A

combining strings

89
Q

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

A

adding numbers and combining strings

90
Q

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

A

boolean

91
Q

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

A

The addition assignment operator (+=) adds the value of the right operand to a variable and assigns the result to the variable.

92
Q

What are objects used for?

A

Objects group together a set of variables and functions to create a model of a something you would recognize from the real world. In an object, variables and functions take on new names, properties and methods.

93
Q

What are object properties?

A

variables that are part of an object

94
Q

Describe object literal notation.

A

The object is the curly braces and their contents. The object is stored in a variable. Separate each key from its value using a colon. Separate each property and method with a comma.

95
Q

How do you remove a property from an object?

A

delete

96
Q

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

A

dot notation or bracket notation

97
Q

What are arrays used for?

A

store a list of values

98
Q

Describe array literal notation.

A

var array = [value1, value2, value3, etc.];

99
Q

How are arrays different from “plain” objects?

A

for arrays, the key for each value is its index number

100
Q

What number represents the first index of an array?

A

0

101
Q

What is the length property of an array?

A

number of items in an array

102
Q

How do you calculate the last index of an array?

A

array.length - 1

103
Q

What is a function in JavaScript?

A

A JavaScript function is a block of code designed to perform a particular task.

104
Q

Describe the parts of a function definition.

A

The function keyword to begin the creation of a new function.
An optional name. (Our function’s name is sayHello.)
A comma-separated list of zero or more parameters, surrounded by () parentheses. (Our sayHello function doesn’t have any parameters.)
The start of the function’s code block, as indicated by an { opening curly brace.
An optional return statement. (Our sayHello function doesn’t have a return statement.)
The end of the function’s code block, as indicated by a } closing curly brace.

105
Q

Describe the parts of a function call.

A

Notice that we are simply writing the name of the function and placing () parentheses next to it.

106
Q

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

A
// defining the sayHello function
function sayHello() {
  var greeting = 'Hello, World!';
  console.log(greeting);
}
// calling the sayHello function
sayHello();
107
Q

What is the difference between a parameter and an argument?

A

parameter is for function definition

argument is for function calling

108
Q

Why are function parameters useful?

A

we can pass information or instructions into our functions

109
Q

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

A

Causes the function to produce a value we can use in our program.
Prevents any more code in the function’s code block from being run.

110
Q

Why do we log things to the console?

A

console.log() is a powerful tool for debugging and an easy way to inspect your variables in the browser.

111
Q

What is a method?

A

A method is a function which is a property of an object.

112
Q

How is a method different from any other function?

A

A function is independent, whereas a method is a function linked with an object.

113
Q

How do you remove the last element from an array?

A

array.pop()

114
Q

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

A

Math.floor()

115
Q

How do you generate a random number?

A

Math.random()

116
Q

How do you delete an element from an array?

A

array.splice()

117
Q

How do you append an element to an array?

A

array.push() or array.unshift()

118
Q

How do you break a string up into an array?

A

string.split()

119
Q

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

A

No, logging to the console

120
Q

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

A

50

121
Q

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

A

no

122
Q

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

A

40

123
Q

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

A

MDN

124
Q

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

A

focus

125
Q

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

A

blur

126
Q

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

A

input

127
Q

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

A

submit

128
Q

What does the event.preventDefault() method do?

A

to prevent the browser from automatically reloading the page with the form’s values in the URL

129
Q

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

A

form’s values in the URL

130
Q

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

A

elements property

131
Q

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

A

value property

132
Q

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

A

if there is an error, it will be hard to find where the error is

133
Q

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

A

catch errors early

134
Q

Why do we log things to the console?

A

easy way to inspect your variables in the browser

135
Q

What is a “model”?

A

representation

136
Q

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

A

web page

137
Q

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

A

web page and everything in it

138
Q

What is a DOM Tree?

A

model of a web page

139
Q

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

A

get El ement Byld ()

querySe 1 ector ()

140
Q

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

A

querySelectorAll()

141
Q

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

A

if your script needs to use the same element(s) more than once, you can store the location of the element(s) in a variable.

142
Q

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

A

console.dir()

143
Q

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

A

The browser needs to parse all of the elements in the HTML page before the JavaScript code can access them.

144
Q

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

A

returns the first Element within the document that matches the specified selector, or group of selectors (valid CSS selector)

145
Q

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

A

The Document method querySelectorAll() returns a static (not live) NodeList representing a list of the document’s elements that match the specified group of selectors.

146
Q

Why do we log things to the console?

A

easy way to inspect your variables in the browser

147
Q

What is the purpose of events and event handling?

A

to have your web page react to the user

148
Q

Are all possible parameters required to use a JavaScript method or function?

A

no

149
Q

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

A

addEventListener()

150
Q

What is a callback function?

A

A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.

151
Q

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

A

event object

152
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 read-only target property of the Event interface is a reference to the object onto which the event was dispatched.

point of interaction

153
Q

What is the difference between these two snippets of code?

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

A

function runs as the page loads vs function runs when the event fires

154
Q

What is the className property of element objects?

A

value of the class attribute

155
Q

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

A

assigning an updated value to className

156
Q

What is the textContent property of element objects?

A

all the text inside

157
Q

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

A

assigning an updated value to the textContent property of that element

158
Q

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

A

no

159
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

more complicated

160
Q

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

A

access it faster

161
Q

What does the transform property do?

A

The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.

162
Q

Give four examples of CSS transform functions.

A

rotate, translate, skew, scale

163
Q

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

A

no

164
Q

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

A

appendChild method

165
Q

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

A

name and value of the attribute

166
Q

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

A

createElement method

appendChild method

167
Q

What is the textContent property of an element object for?

A

manipulate the text content of the element

168
Q

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

A

setAttribute method

class = ‘’

169
Q

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

A

saves time

less code writing

170
Q

What is a breakpoint in responsive Web design?

A

The points at which a media query is introduced

171
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

width will scale with the page (more responsive)

172
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

when the specificity is equal, the sequence of declaration decides which css rule will apply, which is the last rule in the sequence.

173
Q

What is the event.target?

A

reference to the object onto which the event was dispatched

174
Q

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

A

event bubbling

175
Q

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

A

tagName property

176
Q

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

A

selector string

Will return itself or the matching ancestor. If no such element exists, it returns null.

177
Q

How can you remove an element from the DOM?

A

remove method

178
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 an event listener to the parent and find a match on child elements

179
Q

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

A

width

height

180
Q

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

A

viewport meta tag

181
Q

What is the event.target?

A

point of interaction

182
Q

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

A

Turns off the display of an element so that it has no effect on layout (the document is rendered as though the element did not exist)

183
Q

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

A

Parameters
selectorString is a string representing the selector to test.

Return value
result is a boolean value.

184
Q

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

A

getAttribute method

185
Q

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

A

each time you add in new functionality

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

each tab would have its own addEventListener method

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

we would need to change the class name for all elements one at a time

188
Q

What is JSON?

A

JSON is a text-based data format following JavaScript object syntax

189
Q

What are serialization and deserialization?

A

Serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network.

Deserialization is the reverse process: turning a stream of bytes into an object in memory.

190
Q

Why are serialization and deserialization useful?

A

JSON exists as a string — useful when you want to transmit data across a network. It needs to be converted to a native JavaScript object when you want to access the data.

191
Q

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

A

JSON.stringify

192
Q

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

A

JSON.parse

193
Q

How to you store data in localStorage?

A

setItem method

194
Q

How to you retrieve data from localStorage?

A

getItem method

195
Q

What data type can localStorage save in the browser?

A

strings

196
Q

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

A

The beforeunload event is fired when the window, the document and its resources are about to be unloaded.