JavaScript Flashcards

1
Q

What is the purpose of variables?

A

To store data and information to be used for later

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

How do you declare a variable?

A

By using the var keyword and giving it a variable name

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

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

A

By using the “=” sign (assignment operator)

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

What characters are allowed in variable names?

A

Letters, numbers, dollar signs ($), or an underscore (_)

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

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

A

Score and score are different variable names. Lowercase and Uppercase are different

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

What is the purpose of a string?

A

Add new text content into a page

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

What is the purpose of a number?

A

Represent numerical values. They are good for tasks that involve counting or calculating sums.

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

What is the purpose of a boolean?

A

Helpful when determining which part of a script should run.

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

What does the = operator mean in JavaScript?

A

Assignment operator

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

How do you update the value of a variable?

A

Assign a new variable value but with a different value. Don’t use the var keyword

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

What is the difference between null and undefined?

A

Null means an empty or non-existent value. Null is assigned, and explicitly means nothing.

Undefined means a variable has been declared, but the value of that variable has not yet been defined.

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

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

A

It is much clearer which variables are being logged. If you do not include “labels”, it can be very confusing instead of helpful.

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

Give five examples of JavaScript primitives.

A

String, number, undefined, boolean, null

Primitives are stored data/values.

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

What data type is returned by an arithmetic operation?

A

A number

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

What is string concatenation?

A

The process of joining together 2 or more strings to create one new string

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

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

A

It adds numbers or concatenate strings

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)?

A

A boolean

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

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

A

adds the value of the right operand to a variable and assigns the result to the variable

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

What are objects used for?

A

group together a set of variables and functions to create a model of something you would recognize from the real world.

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

What are object properties?

A

A variable that is part of an object. Properties tell us about the object.

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

Describe object literal notation.

A

To access a property or method of an object you use the name of the object, followed by a period, then the name of the property or method you want to access.

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

How do you remove a property from an object?

A

Use the delete keyword and then use dot notation to identify the property or method you want to remove from the object

delete user.firstName

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

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

A

Dot notation or square brackets

hotel.name = ‘park’;
hotel[‘name’] = ‘park‘;

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

What are arrays used for?

A

Store a list of values and items

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

Describe array literal notation.

A

Var with variable name, asmt operator (), [square bracket], values inside of it, [close with square bracket]

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

How are arrays different from “plain” objects?

A

Arrays use numerically indexed instead of property names.

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

What number represents the first index of an array?

A

[0]

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

What is the length property of an array?

A

The number of items in an array

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

How do you calculate the last index of an array?

A

Length - 1

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

What is a function in JavaScript?

A

An object that can allow you to package up code for use later in your program when called.

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

Describe the parts of a function definition.

A
  1. The function keyword to begin the creation of a new function.
  2. An optional name.
  3. A comma-separated list of zero or more parameters, surrounded by () parentheses.
  4. The start of the function’s code block, as indicated by an { opening curly brace.
  5. An optional return statement to stop the function
  6. The end of the function’s code block, as indicated by a } closing curly brace.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Describe the parts of a function call.

A
  1. The function’s name.

2. A comma-separated list of zero or more arguments surrounded by () parentheses.

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?

A

Function definition requires a function keyword. Function call just needs the name.

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

What is the difference between a parameter and an argument?

A

When we define a function, we declare parameters and that when we call a function, we pass it arguments.

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

Why are function parameters useful?

A

Parameters alter function behavior. Useful because it can make modifications to how they run. They are local variables to the functions which are necessary for the function to operate correctly.

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?

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.

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?

A

To test if our code is working

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

What is a method?

A

Methods are functions stored as object properties

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?

A

Methods are attached to 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?

A

.pop

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?

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?

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?

A

array.splice method ( index , how many you want to delete)

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?

A

.push (Add to end)

.unshift (Add to beginning)

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

How do you break a string up into an array?

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?

A

It does not change original string.

Check with .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?

A

36

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?

A

No because the return value is not always something you want to have. Sometimes you just want the functionality.

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?

A

50

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?

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.

A
  1. Greater Than (>)
  2. Less Than (=)
  3. Equal To (==)
  4. Not Equal To( !=)
  5. Strict Not Equal To (!==)
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?

A

Boolean (true or false)

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?

A

Evaluates (or checks) a condition. IF the condition evaluates to true, any statements in the subsequent code block are executed.

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?

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.

A

Start with an if statement, Opening parentheses, condition operand, comparison operator, operand. Closing parentheses. Opening curly bracket. Return statement. Closing Curly Bracket.

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

What are the three logical operators?

A
Logical And (&&)
Logical Or (||)
Logical Not (!)
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 the same condition?

A

Logical And (&&) or Logical 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?

A

Loops is to do something as fast possible a certain number of times.

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?

A

To decide when the loop stop

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?

A

Everytime it goes through a loop

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?

A

Before each loop is run

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?

A

At the start of the for loop. Before the loop begins.

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?

A

After the Initialization has been set. After the final expression runs

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?

A

After the condition statement. After the code 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?

A

Break keyword will break out of loop but not end the function.

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

What does the ++ increment operator do?

A

increments (adds one to) its operand and reassigns the value

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?

A

For…in loop

for (var property in object)

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?

A

To make sure our code is working properly

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

What is a “model”?

A

Representation of a web page with a DOM tree

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?

A

The tree structure of word page

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?

A

All the elements within the DOM tree which are then created into objects.

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

What is a DOM Tree?

A

As a browser loads a web page, it creates a model of that page. The model is called a DOM tree, and it is stored in the browsers’ memory. A hierarchical chart which breaks down all the pieces of a document with four main types of nodes

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.

A

querySelector (get anything), getElementByID (Only get ID)

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.

A

getElementsByClassName, getElementsByTagName, 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?

A

It saves the browser from looking through the DOM tree to find the same element again.

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?

A

console.dir

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

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?

A

It takes a CSS Selector as an argument and returns the first of the matching elements.

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?

A

It takes a CSS Selector as an argument and returns all of those that match in a node list/array

80
Q

Why do we log things to the console?

A

To make sure our code is working properly

81
Q

What is the purpose of events and event handling?

A

Events are things that happen in DOM response to input from a user.
Even handling trigger javascript code and run code in response to events

82
Q

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

A

no

83
Q

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

A

AddEventListener() method

84
Q

What is a callback function?

A

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.

85
Q

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

A

The event object

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

87
Q

What is the difference between these two snippets of code?

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

A

The second one has a return value so it’s calling a function, which we don’t want.

88
Q

What is the className property of element objects?

A

sets or returns the class name of an element (the value of an element’s class attribute).

89
Q

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

A

(Name of class).className = (‘string of new class name’)

90
Q

What is the textContent property of element objects?

A

The textContent property represents the text content of the node and its descendants.

91
Q

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

A

TextContent and the asmt operator

92
Q

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

A

No

93
Q

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

A

Makes it easier to manipulate and keep track of things. Don’t need to rely on DOM.

94
Q

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

A

focus

95
Q

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

A

blur

96
Q

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

A

input

97
Q

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

A

The Submit event is fired. It’s fired on the form element

98
Q

What does the event.preventDefault() method do?

A

It prevents an event from being handled with it’s default behavior.

99
Q

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

A

The browser will automatically reload the page with the form’s values in the URL.

100
Q

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

A

Elements property

101
Q

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

A

Value property

102
Q

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

A

You could write a lot of code and not know where the problem is

103
Q

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

A

You can make sure your code is working the whole time and catch errors early

104
Q

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

A

It does not because it’s not specified where on the page it should go

105
Q

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

A

appendChild

106
Q

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

A

.setAttribute(name, value)

107
Q

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

A

Create element, append it to child of something that is on the page.

108
Q

What is the textContent property of an element object for?

A

To set the text content of an element

109
Q

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

A

setAttribute, className

110
Q

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

A

Defining a function allows you to reuse it to save time.

Helps to organize html you’re creating

111
Q

What is the event.target?

A

a reference to the object onto which the event was dispatched. The event interacted with by the user

112
Q

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

A

Because event bubbling goes all the way up to the parent.

113
Q

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

A

event.target.tagName

114
Q

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

A

Takes a selector as an argument and returns the closest parent it has. It can also return itself.

115
Q

How can you remove an element from the DOM?

A

Remove method

116
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

Adding it to the parent and have it bubble up.

117
Q

What is the event.target?

A

a reference to the object onto which the event was dispatched. The event interacted with by the user

118
Q

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

A

the affected element will disappear.

119
Q

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

A

a string representing the selector to test. Returns boolean value. true if the element would be selected by the specified selector string; otherwise, returns false

120
Q

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

A

.getAttribute()

121
Q

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

A

All the time.

122
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

Put individual event listeners on each of the tabs.

123
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

You would write an if statement for each tab

124
Q

What is JSON?

A

A standard text-based data format following JavaScript object syntax.
JavaScript Object Notation

125
Q

What are serialization and deserialization?

A

Serialization is the process of turning an object in memory into a stream of bytes

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

126
Q

Why are serialization and deserialization useful?

A

Serialized code can be transferred over a network or stored in a persistent storage and brought back with deserialization in the same state.

127
Q

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

A

JSON.stringify()

128
Q

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

A

JSON.parse()

129
Q

How to you store data in localStorage?

A

localStorage.setItem(key, value);

localStorage.setItem(‘myCat’, ‘Tom’);

130
Q

How to you retrieve data from localStorage?

A

localStorage.getItem(key);

131
Q

What data type can localStorage save in the browser?

A

JSON strings

132
Q

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

A

when the window, the document and its resources are about to be unloaded.

133
Q

What is a method?

A

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

134
Q

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

A

A method definition is the function.
A method call is just the objectName.method()

Ex:
var calculator = {
  add: function (x, y) {
    var sum = x + y;
    return sum;
 };
In example, calculator.add(x, y) is method call. 
Add is method definition.
135
Q

Describe method definition syntax (structure).

A

Give property name, define a function with parameters, opening curly brace, closing curly brace

Ex: var calculator = {
  add: function (x, y) {
    var sum = x + y;
    return sum;
 };
136
Q

Describe method call syntax (structure).

A

Start with the object variable name, dot, name of the method with parameters

objectName.method()

Ex: var calculator = {
  add: function (x, y) {
    var sum = x + y;
    return sum;
 };

method call is calculator.add(x, y)

137
Q

How is a method different from any other function?

A

Method is attached to an object. Function is defined outside.

138
Q

What is the defining characteristic of Object-Oriented Programming?

A

objects can contain both data (as properties) and behavior (as methods).

139
Q

What are the four “principles” of Object-Oriented Programming?

A

Abstraction
Encapsulation
Inheritance
Polymorphism

140
Q

What is “abstraction”?

A

the process of removing physical, spatial, or temporal details or attributes in the study of objects or systems to focus attention on details of greater importance

141
Q

What does API stand for?

A

Application Programming Interface

142
Q

What is the purpose of an API?

A

to give programmers a way to interact with a system in a simplified, consistent fashion:

143
Q

What is this in JavaScript?

A

an implicit parameter of all JavaScript functions.

the value of this is determined by how a function is called

144
Q

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

A

It means that it is available in a function’s code block even though it was never included in the function’s parameter list or declared with var

145
Q

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

A

When the function is called, call time.

146
Q
What does "this" refer to in the following code snippet?
var character = {
  firstName: 'Mario',
  greet: function () {
    var message = 'It\'s-a-me, ' + this.firstName + '!';
    console.log(message);
  }
};

Given the above character object, what is the result of the following code snippet? Why?

character.greet();

Given the above character object, what is the result of the following code snippet? Why?

var hello = character.greet;
hello();
A

This refers to character object.

It’s-a-me, Mario! Because this refers to character object.

It’s-a-me, undefined! Because the value of this is determined when the function is called, not when it is defined.

147
Q

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

A

the value of this can be recognized as “the object to the left of the dot” when the function is called (as a method).

148
Q

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

A

The object before the method. If nothing is there, it will be the global window.

149
Q

What kind of inheritance does the JavaScript programming language use?

A

prototype-based (or prototypal) inheritance

150
Q

What is a prototype in JavaScript?

A

object that contains properties and (predominantly) methods that can be used by other objects.

151
Q

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

A

They all have a prototype object within them.

152
Q

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

A

In it’s prototype chain

153
Q

What does the new operator do?

A

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

154
Q

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

A

prototype

155
Q

What does the instanceof operator do?

A

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.

156
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.
Passing a function into another function as an argument

157
Q

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

A

By setting a delay on the setTimeout()

158
Q

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

A

By using a set interval

159
Q

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

A

0

160
Q

What do setTimeout() and setInterval() return?

A

setTimeout()
The returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout().

setInterval()
The returned intervalID is a numeric, non-zero value which identifies the timer created by the call to setInterval(); this value can be passed to clearInterval() to cancel the interval.

161
Q

What is a client?

A

Clients, also known as service requesters, are pieces of computer hardware or server software that request resources and services made available by a server.

162
Q

What is a server?

A

the providers of a resource or service

163
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

GET Method

164
Q

What three things are on the start-line of an HTTP request message?

A

1) An Http method
2) the request target (Usually URL)
3) Http version

165
Q

What three things are on the start-line of an HTTP response message?

A

Protocol version, a status code, status text

166
Q

What are HTTP headers?

A

HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon (:), then by its value.

167
Q

Where would you go if you wanted to learn more about a specific HTTP Header?

A

MDN

168
Q

Is a body required for a valid HTTP request or response message?

A

No

169
Q

What is AJAX?

A

is a programming practice of building complex, dynamic webpages using a technology known as XMLHttpRequest.

170
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript And XML

171
Q

Which object is built into the browser for making HTTP requests in JavaScript?

A

XMLHttpRequest

172
Q

What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?

A

Load event

173
Q

An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?

A

Because of prototype

174
Q

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

A

A block of code written in between curly braces. Ex: If statement, for loop, functions

175
Q

What does block scope mean?

A

A block scoped variable means that the variable defined within a block will not be accessible from outside the block

176
Q

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

A

Block scoped

177
Q

What is the difference between let and const?

A

Let is immutable meaning you change the value. Const is not immutable.

178
Q

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

A

Because the cont only holds a pointer value to where the array is stored in memory. We’re not changing the memory address at all when pushing.

Because it functions similarly to updating an object values. It’s already declared and assigned, you’re just adding to the “list” that the constant points to.

179
Q

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

A

If the value never changes, use const. If the value of the variable needs to change then you use let.

Make everything const, second you find out you have to change it, change to let. Const more efficient.

180
Q

What is the syntax for writing a template literal?

A

Wrap text in back ticks `. Substitute variables using ${}

181
Q

What is “string interpolation”?

A

the ability to substitute part of the string for the values of variables or expressions. Substitute variables using ${} wrapped in curly braces

182
Q

What is destructuring, conceptually?

A

Breaking down the contents of an object or an array into variables to be called later

183
Q

What is the syntax for Object destructuring?

A

const { firstName, lastName, middleName } = person;
const { firstName: fname, lastName: lname } = person;
^ To change the name of the property ^

const foo = ['one', 'two', 'three'];
const [red, yellow, green] = foo;

console. log(red); // “one”
console. log(yellow); // “two”
console. log(green); // “three”

184
Q

What is the syntax for Array destructuring?

A

const [x, y, z] = person;

185
Q

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

A

Arrays use brackets
Destructuring object takes place on the left hand sind on equal sign
Destructing array take place on the right hand side of equal sign

186
Q

What is the syntax for defining an arrow function?

A
let add = (x, y) => x + y;
let add = (x, y) => {
187
Q

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

A

Only the first line will be returned. It is an implicit return.
The parenthesis are returning a single value, the curly braces are executing multiple lines of code like a normal function.

188
Q

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

A

Arrow functions have a lexical this and its value within the arrow function is determined by the surrounding scope.

189
Q

What is a CLI?

A

Command Line Interfaces

190
Q

What is a GUI?

A

Graphical User Interface

191
Q

Give at least one use case for each of the commands listed in this exercise

A

Man: gives manual page for any command (manual)

cat: concatenate files and view contents of file (concatenate)
ls: list directory contents (list segment)
pwd: print name of current/working directory to check which folder you are in (print working directory)
echo: display a line of text
touch: create new files. Also change timestamps
mkdir: create new directories (make directory)
mv: move (rename) files or folders (move)
rm: delete files or directories (remove). Use -r to remove contents within
cp: copy files or directories (copy). Use -r to copy contents within

192
Q

What are the three virtues of a great programmer?

A

Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don’t have to answer so many questions about it.
Impatience: Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to.
Hubris: The quality that makes you write (and maintain) programs that other people won’t want to say bad things about.

193
Q

How are ES Modules different from CommonJS modules?

A

Es6 uses import/export statements

CommonJS uses require/module.export

194
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules.

195
Q

Front End Uses

A

ES Modules

Import/export statements

196
Q

Back End uses

A

CommonJS modules

require()/module.export