JavaScript Flashcards

1
Q

What is the purpose of variables?

Javascript-primitives-and-variables

A

To store information/data.

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

How do you declare a variable?

Javascript-primitives-and-variables

A

You write var, let, or const; the name of the variable; and an assignment operator.

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

Javascript-primitives-and-variables

A

You use an equal sign

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

What characters are allowed at the start of variable names?

Javascript-primitives-and-variables

A

$, underscore, and letters.

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”?
(Javascript-primitives-and-variables)

A

A variable with a capital is different than a variable without one.

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

What is the purpose of a string?

Javascript-primitives-and-variables

A

To store text content data.

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

what is the purpose of a number?

Javascript-primitives-and-variables

A

For data that needs numbers.

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

What is the purpose of a boolean?

Javascript-primitives-and-variables

A

To give us a choice between true or false.

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

What does the = operator mean in JavaScript

Javascript-primitives-and-variables

A

It means 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?

Javascript-primitives-and-variables

A

You assign the variable a different 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 underfined?

Javascript-primitives-and-variables

A

Null is for values that the coder can change later.

Undefined could be on an accident

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?
(Javascript-primitives-and-variables)

A

To prevent confusion

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

Give five examples of JavaScript primitives.

Javascript-primitives-and-variables

A

String, array, object, integer, 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?

Javascript-operators-and-expressions

A

Numbers.

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

What is string concatenation?

Javascript-operators-and-expressions

A

The joining of two or more strings together using the plus operator.

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
(Javascript-primitives-and-variables)
A

It adds numbers and joins strings together.

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 (, ===, etc)?
(Javascript-operators-and-expressions)

A

A boolean.

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

What does the += operator do?

Javascript-operators-and-expressions

A

It adds the variable and anything else and assigns the result of the expression to that variable.

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

What are objects used for?

Javascript-objects

A

Store related info for easy access later

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

What are object properties?

Javascript-objects

A

They are attached to objects to define their characteristics.

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

Describe object literal notation.

Javascript-objects

A

Curly-braces , {}

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?

Javascript-objects

A

Use the delete operator on the property of the object.

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?
(Javascript-objects)

A

By using the dot method and giving it a different value or changing it in the object literal.

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

What are arrays used for?

Javascript-arrays

A

Storing related information in a specific order.

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

Describe array literal notation.

Javascript-arrays

A

Brackets, []

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

How are arrays different from “plain” objects?

Javascript-arrays

A

They store information in a specific order.

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?

Javascript-arrays

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 the array?

Javascript-arrays

A

The number of elements in the array or string.

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?

Javascript-arrays

A

You do array[array.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?

Javascript-functions

A

Self contained modules of code that accomplish a specific 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.

Javascript-functions

A

Function, optional name, parameter, code block, optional return.

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

Describe the parts of a function call.

Javascript-functions

A

Sometimes a function keyword, sometimes a name, opening/closing parenthesis with a parameter sometimes in them, sometimes a arrow function operator, sometimes a curly bracket, a code block and sometimes a return statement within that code block.

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 a function definition?
(Javascript-functions)

A

Function calls have opening/closing parenthesis and their value is that of their return value. Function definitions are only being defined and don’t have a value until called.

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?

Javascript-functions

A

parameters are temporary. Arguments are the values you’re actually using.

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

Why are function parameters useful?

Javascript-functions

A

To prevent confusion and so you know exactly what type of argument should go in there

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

What two effects does a return statement have on the behavior of a function?
(Javascript-functions)

A

It returns the value and ends the function call immediately.

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

Why do we log things to the console?

Javascript-method

A

To check our values and make sure they are correct.

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

What is a method

Javascript-method

A

A function that is a property of an object.

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

How is a method different from any other function?

Javascript-method

A

Method’s are stored on an object

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

How do you remove the last element from an array?

Javascript-method

A

.pop() method

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

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

Javascript-method

A

Math.floor

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

How do you generate a random number?

Javascript-method

A

Math.random

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

How do you delete an element from an array?

Javascript-method

A

Use the .splice() method

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

How do you append an element to an array?

Javascript-method

A

.push() method

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

How do you break a string up in to an array?

Javascript-method

A

.split() method

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

Do string methods change the original string? How would you check if you weren’t sure?
(Javascript-method)

A

They do not. console.log

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

Roughly how many string methods are there according to the MDN Web docs?
(Javascript-method)

A

A LOOOOOT

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

Is the return value of a function or method useful in every situation?
(Javascript-method)

A

No, it’s not always used

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

Roughly how many array methods are there according to the MDN Web docs?
(Javascript-method)

A

A LOOOOOT

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

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

A

MDN

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

Give 6 examples of comparison operators.

Javascript-if

A

&&, ===, !==, ||, <=, >=, %

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

What data type do comparison expressions evaluate to?

Javascript-if

A

Boolean.

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

What is the purpose of an if statement?

Javascript-if

A

They allow code to only execute under certain conditions.

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

Is else required in order to use an if statement?

Javascript-if

A

No

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

Describe the syntax (structure) of an if statement.

Javascript-if

A

if statement, conditional statement, and conditional code block

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

What are the three logical operators?

Javascript-if

A

&&, ||, and !

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

How do you compare two different expressions in a conditional statement?
(Javascript-if)

A

&&, ||, or !

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

What is the purpose of a loop?

Javascript-loops

A

To repeat a process until conditions are met.

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

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

Javascript-loops

A

To repeat the loop until certain conditions are met.

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

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

Javascript-loops

A

Every time the code gets executed.

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

When does the condition expression of a while loop get evaluated?
(Javascript-loops)

A

Before each iteration.

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

When does the initialization expression of a for loop get evaluated?
(Javascript-loops)

A

At the start of the loop.

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

When does the condition expression of a for loop get evaluated?
(Javascript-loops)

A

Before each iteration block.

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

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

Javascript-loops

A

After the conditional block.

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

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

A

Break statement.

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

What does the ++ increment operator do?

Javascript-loops

A

It increases the variable by 1

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

How do you iterate through the keys of an object?

Javascript-loops

A

For, in loop

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

Why do we log things to the console?

dom-querying

A

To check our values and make sure they’re correct.

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

What is a “model”?

dom-querying

A

The representation of something without being it.

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

Which “document” is being referred to in the phrase Document Object Model?
(dom-querying)

A

HTML doc

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

What is the word “object” referring to in the phrase Document Object Model?
(dom-querying)

A

Data

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

What is a DOM Tree?

dom-querying

A

A JavaScript object model that holds elements and their attributes, text, and children.

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

Give two examples of document methods that retrieve a single element from the DOM.
(dom-querying)

A

querySelector(), getById(),

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

Give one example of a document method that retrieves multiple elements from the DOM at once.
(dom-querying)

A

querySelectorAll()

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

Why might you want to assign the return value of a DOM query to a variable?
(dom-querying)

A

To easily change it’s value later.

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

What console method allows you to inspect the properties of a DOM element object?
(dom-querying)

A

console.dir()

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

Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?
(dom-querying)

A

HTML content needs to load before the script.

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

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

A

It takes a string css selector as it’s argument and returns the first selector it finds.

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

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

A

It takes a string css selector as it’s argument and returns a nodelist.

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

Why do we log things to the console?

dom-events

A

To check our values and make sure they’re correct.

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

What is the purpose of events and event handling?

dom-events

A

So you can create a reaction to something the user does.

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

Are parameters required to use a JavaScript method or function?
(dom-events)

A

No, some are optional.

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

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

A

addEventListener

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

What is a callback function?

dom-events

A

When a function is passed into another or in general as a variable.

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

What object is passed into an event listener callback when the event fires?
(dom-events)

A

An object that contains all the data from the event that happened.

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

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

A

The element the event occurred on. console.log(). MDN

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

What is the difference between these two snippets of code?
element.addEventListener(‘click’, handleClick)
element.addEventListener(‘click’, handleClick())
(dom-events)

A

First one passed the function definition (correct).

Second one the return value is replacing the function.

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

What is the className property of element objects?

dom-manipulation

A

It’s their class names. That of which you can focus on and change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q
How do you update the CSS class attribute of an element using JavaScript?
(dom-manipulation)
A

By using the className and classList properties. You can use them to change or assign new properties.

90
Q

What is the textContent property of element objects?

dom-manipulation

A

It’s an elements string content.

91
Q

How do you update the text within an element using JavaScript?
(dom-manipulation
)

A

You use textContent property and assign it a value.

92
Q

Is the event parameter of an event listener callback always useful?
(dom-manipulation)

A

No.

93
Q

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

A

It would be more complicated/confusing.

94
Q

Why is storing information about a program in variables better than only storing it in the DOM?
(dom-manipulation)

A

So it can be reused and keep the languages separate.

95
Q

What event is fired when a user places their cursor in a form’s content?
(javascript-forms)

A

Focus

96
Q

What event is fired when a user’s cursor leaves a form control?
(javascript-forms)

A

Blur

97
Q

What event is fired as a user changes the value of a form control?
(javascript-forms)

A

Input

98
Q

What event is fired when a user clicks the “submit” button within a form?
(javascript-forms)

A

Submit

99
Q

What does the event.preventDefault() method do?

javascript-forms

A

Prevents the browsers default action when an action occurs.

100
Q

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

javascript-forms

A

It stops HTML from trying to send the data itself.

101
Q

What property of a form element object contains all of the form’s controls.
(javascript-forms)

A

elements property.

102
Q

What property of a form
controls what objects get and set its value?
(javascript-forms)

A

Value

103
Q

What is one risk of writing a lot of code without checking to see if it works so far?
(javascript-forms)

A

It’s harder to find bugs.

104
Q

What is an advantage of having your console open when writing a JavaScript program?
(javascript-forms)

A

It will instantly tell you when an error occurs

105
Q

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

A

No.

106
Q

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

dom-creation

A

appendChild, append.

107
Q

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

A

An attribute and it’s value, both as a string (DOM string).

108
Q

What steps do you need to take in order to insert a new element into the page?
(dom-creation)

A

queryselector() the parent element, document.createElement(), & appendChild.

109
Q

What is the textContent property of an element object for?

dom-creation

A

It stores textContent of an HTML element.

110
Q
Name two ways to set the class attribute of a DOM element.
(dom-creation)
A

.className, .classList, and .setAttribute.

111
Q

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

A

Adds reusability, easier testing, and to give code a name.

112
Q

What is the event.target?

dom-event-delegation

A

The element the event happened on

113
Q

Why is it possible to listen for events on one element that actually happen its descendent elements?
(dom-event-delegation)

A

Due to event bubbling.

114
Q

What DOM element property tells you what type of element it is?
(dom-event-delegation)

A

element.tagName

115
Q

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

A

A css-selector as a string & returns its closest ancestor.

116
Q

How can you remove an element from the DOM?

dom-event-delegation

A

.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?
(dom-event-delegation)

A

You’d put the listener on an ancestor element and use event.target/bubbling to select the new elements

118
Q

What is the event.target?

javascript-view-swapping

A

The element the event happens on.

119
Q

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

javascript-view-swapping

A

The element is invisible from viewport and removed from document flow.

120
Q

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

A

It takes elements and returns a Boolean.

121
Q

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

javascript-view-swapping

A

Using the .getAttribute() method.

122
Q

At what steps of the solution would it be helpful to log things to the console?
(javascript-view-swapping)

A

Every step of the solution.

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?
(javascript-view-swapping)

A

You would have to addEventListener’s to every element.

124
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?
(javascript-view-swapping
)

A

You would have a massive conditional block

125
Q

What is JSON?
(javascript-and-json
)

A

String data interchangeable between computers.

126
Q

What are serialization and deserialization?

javascript-and-json

A

Serialization: Turn data into a set JSON order, so it can be sent out.
Deserialization: Take JSON and organize it for computers.

127
Q

Why are serialization and deserialization useful?

javascript-and-json

A

Allows you to pass data in a form that all computers can interpret.

128
Q

How do you serialize a data structure into a JSON string using JavaScript?
(javascript-and-json
)

A

.stringify()

129
Q

How do you deserialize a JSON string into a data structure using JavaScript?
(javascript-and-json)

A

.parsify()

130
Q

How do you store data in localStorage?

javascript-local-storage

A

set.Item() method

131
Q

How to you retrieve data from localStorage?

javascript-local-storage

A

get.Item() method

132
Q

What data type can localStorage save in the browser?

javascript-local-storage

A

String values.

133
Q

When does the ‘beforeunload’ event fire on the window object?
(javascript-local-storage)

A

Immediately before any action that closes or refreshes the browser.

134
Q

What is the difference between prototype and __proto__?

javascript-contructors

A

prototype is on the constructor itself. __proto__ is an object on the new constructor object.

135
Q

What does the new operator do?

javascript-contructors

A

Lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.

136
Q

What property of JavaScript functions can store shared behavior for instances created with new?
(javascript-contructors)

A

prototype property.

137
Q

What does the instanceof operator do?

javascript-contructors

A

Tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. The return value is a boolean value.

138
Q

What is a callback function?

javascript-timers

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.

139
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?
(javascript-timers)

A

setTimeout() method.

140
Q

How can you set up a function to be called repeatedly without using a loop?
(javascript-timers)

A

setInterval() method.

141
Q

What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
(javascript-timers)

A

0, or instant

142
Q

What do setTimeout() and setInterval() return?

javascript-timers

A

They return an id that can be used to stop them.

143
Q

What is a client?

http-messages

A

A program or device that initiates communication sessions with servers, which await incoming requests from clients.

144
Q

What is a server?

http-messages

A

A piece of computer hardware or software that provides extra functionality to clients.

145
Q

Which HTTP method does a browser issue to a web server when you visit a URL?
(http-messages)

A

GET.

146
Q

What three things are on the start-line of an HTTP request message?
(http-messages)

A

The HTTP method, request target, and the HTTP version.

147
Q

What three things are on the start-line of an HTTP response message?
(http-messages)

A

HTTP version, status code, status text.

148
Q

What are HTTP headers?

http-messages

A

A case-insensitive string followed by a colon (‘:’) and a value whose structure depends upon the type of the header. They let the client and the server pass additional information with an HTTP request or response.

149
Q

Where would you go if you wanted to learn more about a specific HTTP Header?
(http-messages)

A

mdn.

150
Q

Is a body required for a valid HTTP request or response message?
(http-messages)

A

Nope.

151
Q

What is AJAX?

javascript-ajax

A

It allows the developer to make updates to elements on the page using servers without having to reload the page.

152
Q

What does the AJAX acronym stand for?

javascript-ajax

A

Asynchronous JavaScript and XML.

153
Q

Which object is built into the browser for making HTTP requests in JavaScript?
(javascript-ajax)

A

XMLHttpRequest().

154
Q

What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?
(javascript-ajax)

A

The ‘load’ event.

155
Q

What is a code block? What are some examples of a code block?
(es6-const-let)

A

Code that occurs between two curly braces. Loops, conditionals, etc.

156
Q

What does block scope mean?

es6-const-let

A

All the variables that are available inside that block.

157
Q

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

es6-const-let

A

block scope.

158
Q

What is the scope of a variable declared with var

es6-const-let

A

function scope.

159
Q

What is the difference between let and const?

es6-const-let

A

let variables can be reassigned a value. Attempting to reassign const with throw an error.

160
Q

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

A

Because you are not reassigning it’s value.

161
Q

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

es6-const-let

A

If you aren’t going to reassign the value, then use const.

162
Q

What is the syntax for writing a template literal?

es6-template-literals

A

A backtick, followed by strings and/or ${ }.

163
Q

What is “string interpolation”?

es6-template-literals

A

When values are substituted into the string for placeholders.

164
Q

What is destructuring, conceptually?

es6-destructuring

A

Extracting the information from a variable and assigning it’s values to other variables

165
Q

What is the syntax for Object destructuring?

es6-destructuring

A

You often, but not always, start with a declaration followed by an object literal that contains 0 or more properties that sometimes have a colon followed by a variable name. Then there’s an assignment operator followed by the variable being destructured.

166
Q

What is the syntax for Array destructuring?

es6-destructuring

A

Often, but not always, starts with a declaration followed by an array literal. Within that is a non-zero amount of comma separated variables followed by the end of the array literal. Then there’s an assignment operator and the variable being destructured.

167
Q

How can you tell the difference between destructuring and creating Object/Array literals?
(es6-destructuring)

A

If you’re destructuring, the brackets go on the left side. Creating, the brackets go on the right side.

168
Q

What is the syntax for defining an arrow function?

es6-arrow-functions

A

Parenthesis with 0 or more parameters inside followed by an arrow keyword after that. Sometimes has curly braces following that.

169
Q

When an arrow function’s body is left without curly braces, what changes in its functionality?
(es6-arrow-functions)

A

As long as it’s a single expression, the return statement is implied and not needed.

170
Q

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

(es6-arrow-functions)

A

Arrow functions capture the value of the this object when it was defined.

171
Q

When is the value of this determined within a normal function?
(es6-arrow-functions)

A

The value of this is determined at call time.

172
Q

What is “syntactic sugar”?

es6-classes

A

syntax within a programming language that is designed to make things easier to read or to express.

173
Q

What is the typeof an ES6 class?

es6-classes

A

A function.

174
Q

What is “refactoring”?

es6-classes

A

The act of changing your code overtime for any reason, while maintaining it’s previous function.

175
Q
Describe ES6 class syntax.
(es6-classes)
A

The class keyword definition, class name, open curly-brace for the class body, the class body, end of class body.

176
Q

What does AMD modules stand for?

A

Asynchronous Module Definition

177
Q

How are ES Modules different from CommonJS modules?

es6-classes

A

They don’t use require, they use import/export keyword, and they are officially part of the JavaScript language.

178
Q

What kind of modules can Webpack support?

webpack-intro

A

Synchronous and Asynchronous modules.

Es, CommonJs, AMD, and asset, and Web assembly modules.

179
Q

What is Webpack?

webpack-intro

A

A webpack is a module bundler

180
Q

How do you add a devDependency to a package?

webpack-intro

A

npm install (–save-dev) (webpack/webpack-cli)

181
Q

What is an NPM script?

webpack-intro

A

commands you can make npm run

182
Q

How do you execute Webpack with npm run?

webpack-intro

A

npm run (the property of script that you want to run)

183
Q

What does webpack-cli do?

A

It looks at arguments that your webpack commands do allowing you to modify your command line

184
Q

When importing or exporting what are curly braces for?

A

They are for named export/import values, instead of default values.

185
Q

What are the three states a Promise can be in?

es6-promises

A

Pending, fulfilled, or reject.

186
Q

How do you handle the fulfillment of a Promise?

es6-promises

A

With the then method, await keyword, Promise.resolve(), etc

187
Q

How do you handle the rejection of a Promise?

es6-promises

A

With the catch method

188
Q

What is Array.prototype.filter useful for?

array-filter

A

It filters your array and returns another array, but only with the values you want from the main array.

189
Q

What is Array.prototype.map useful for?

array-map

A

It takes an array and returns another array with code in the code block executed on each element in the array.

190
Q

What is Array.prototype.reduce useful for?

array-reduce

A

It goes through the array element-by-element, adding the current elements value to the result from the previous one until there are no more elements to add. (The result is the running sum of all the previous steps)

191
Q

How do you mount a React element to the DOM?

react-element

A

The render method (Only called once.

192
Q

What is React?

react-element

A

React is a JavaScript library for creating user interfaces.

193
Q

What is a React element?

react-element

A

Plain objects

194
Q

What does react do to any other elements within it’s container?

A

It deletes everything and takes ownership of the container.

195
Q

What do libraries do?

A

You call their code.

196
Q

What do frameworks do?

A

They call your code.

197
Q

What is a Plug-in?

babel-intro

A

A software component that adds a specific feature to an already existing computer program. (ex. VSCode extensions)

198
Q

What is Babel?

babel-intro

A

A JavaScript compliler. (Toolkit primarily for JavaScript that converts modern, future, or alternative JavaScript to older versions for older browsers).

199
Q

What is a Webpack loader?

babel-intro

A

Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you import or “load” them. (Bridges between source codes).

200
Q

How can you make Babel and Webpack work together?

babel-intro

A

You use babel-loader, which allows babel to preprocess webpack code.

201
Q

In a build step what is an Author and what is an Artifact?

A

Author is what we want to use. Often incompatible with browsers, so it needs a bundler (webpack)
Artifact with what the client/browser gets. Fewer files has an older syntax, and requires a bundler for new files

202
Q

What does Babel do by itself?

A

Nearly nothing; requires plugins for extra functionality.

203
Q

What is JSX?

react-jsx

A

A syntax extension that supports JavaScript + more.

204
Q

Why must the React object be imported when authoring JSX in a module?
(react-jsx)

A

Because the actual code uses the React create element method.

205
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
(react-jsx)

A

You connect them to the babel-loader and then add the react plugin.

206
Q

What is a React component?

react-function-components

A

A component allows you to split the UI into independent, reusable pieces, and think about each piece in isolation.

207
Q

How do you define a function component in React?

react-props-and-expressions

A

You define with the function keyword or with arrow function syntax, brackets, return statement in the code block, and end brackets.

208
Q

How do you mount a component to the DOM?

react-props-and-expressions

A

You use the render method of ReactDOM.

209
Q

What are props in React?

react-props-and-expressions

A

They are objects

210
Q

How do you pass props to a component?

react-props-and-expressions

A

you would create a react element with a prop name with an assignment operator and a value.

211
Q

How do you write JavaScript expressions in JSX?

react-props-and-expressions

A

Surround the code in a parenthesis.

212
Q

How do you create “class” component in React?

react-class-components

A

Use the class keyword, the name of the class, the extends keyword, and the Component property of the React object, Must have a render method in it that returns a react element.

213
Q
How do you access props in a class component?
(react-class-components)
A

Using the this object.

214
Q
What does render() within a class do?
(react-class-components)
A

the render method within a class object returns a picture of what the DOM looks like.

215
Q

What is the purpose of state?

react-events-and-state

A

The purpose of state in react is to keep track of values that change over time.

216
Q

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

react-events-and-state

A

As a prop.

217
Q

What Array method is commonly used to create a list of React elements?
(react-rendering-lists)

A

The map method.

218
Q

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

A

The id of the list item.

219
Q

What does tree (directory name) do?

A

It shows a tree of that directory and it’s children.

220
Q

What are controlled components?

A

Components that maintain their own state and update it based on user input.

221
Q

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

A

the onChange and value properties.