JavaScript Flashcards

1
Q

What is the purpose of variables?

A

Variables are used to store information for the computer to be able to reference back to. It brings permanence to data.

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

How do you declare a variable?

A

You declare a variable with the var keyword followed by the variable name. A variable can start with a letter, $, or _

var fullName

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

If a variable has not been declared yet, you use the variable keyword, the variable name, and then initialize the variable with the assignment operator =

var fullName = ‘Brandon Moy’;

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

Lowercase letters, uppercase letters (camel case), numbers, $, and _

Variables cannot start with numbers

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

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

A

It means that the capitalization must be consistent across the entire variable

var Score is different from var score

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

A string it used to record a data type that lets us store any types of characters

e.g. ‘Hello World!’

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

A data type number is recorded to recall a number value (can be used for calculations or incrementation)

var width = 10;
var height = 10;
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

A boolean is used to define a value as true or false. It is used for decision making.

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

What does the = operator mean in JavaScript?

A

The = operator assigns the value on the right side to the variable on the left side

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

You can update a value of a variable by assigning it a new value further down the script

early: var fullName = ‘Brandon’;
later: fullName = ‘Brandon Moy’;

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

Both are empty values but for different purposes. Null is a nonexistent or invalid object (cannot be used by JavaScript [can be used as a placeholder as null can ONLY be assigned]) whereas undefined is returned by JavaScript when there is no value assigned

Null - used by programmers to show empty
Undefined - JavaScript’s way to show empty

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

Labels print information on the values being logged to the console for more ease of readability

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, Numbers, Boolean, Null, Undefined

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

What data type is returned by an arithmetic operation?

A

A number data type is returned by an arithmetic operation. If a string is put through an arithmetic operation JavaScript will print back NaN (not a number)

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

What is string concatenation?

A

String concatenation is when two or more strings are combined together to create a new string.

‘Hello’ + ‘ ‘ + ‘World!’ will return as ‘Hello World!’

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

The + operator can be used as arithmetic operator or string concatenator

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

When comparing two values a boolean is returned for the value of the comparison

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

The += operator adds the new value to the starting variable and then assigns this new combined value back 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

Objects are used to store multiple pieces of information into location without affecting other data and multiple pieces of information into one location to call back to.

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

What are object properties?

A

Object properties are just variables assigned to one object

var objectName = {
  property: propertyValue
};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Describe object literal notation.

A

You use the variable keyword, the variable name, and you assign a grouping of properties to it inside of { }. Each property is notated property: value and a comma is used to separate the properties.

var objectName = {
property: value,
property2: value
};

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

How do you remove a property from an object?

A

delete operator is used to remove a property

delete object.property;

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 - object.property = newValue;

Square bracket - object[‘property’] = newValue;

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

What are arrays used for?

A

Arrays are used for storing a list of data. e.g. List of students, colors, hotels, cars

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

Describe array literal notation.

A

Square bracket with value separated by a comma

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

How are arrays different from “plain” objects?

A

Objects will assign a value to a property for the key value pair while an array assigns the value to an index number for the key value pair. Arrays have set orders and length properties.

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

The number for the first index of an array is 0 since computers start counting from 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 length property of an array is a count of how many values are stored in the 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

You can subtract 1 from the length of the array.

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

What is a function in JavaScript?

A

A list of steps that can be reused multiple times in the code.

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

The function keyword, the (optional) name of the function, the parameter list separated by commas and surrounded by parenthesis, the open curly brace for the function block, code within the code block, probably a 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.

A

The function name, 0 or more arguments surrounded by parenthesis

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

The definition has { } for code block, function keyword

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

What is the difference between a parameter and an argument?

A

Parameter - used in definition, placeholder for a future value
Argument - used in function call, actually value provided

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

Why are function parameters useful?

A

Parameters allow us to create variance. They allow us to create ONE function for MULTIPLE uses

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

1) It allows the results to be used outside of the function

2) It stops the function

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

We log things to the console so that developers can check and see the output and the state of variables and functions. The console is the developers way of communicating with JavaScript

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

What is a method?

A

A method is a reference to a function that is used as a property of an object. E.g. Math.max() is the max method OF the math 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?

A

A method is called as a property of the object it is pulling the information off of.

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

You use the .pop() method of the array object to remove the last element

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

You can use the .floor() method of the array object to round down to the nearest integer

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

The .random() method of the max object will generate a random number between 0 and 1 which can then be multiplied by the length of the array you want to generate randomly from

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

The .splice(start, quantity) can delete elements from an array

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

You use the .push() method to append an element to an array

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

Use the .split() method with the argument string value ‘ ‘ to separate the string at the argument locations

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

They do not change the original string. We can console.log() the original variable housing the string we change. Instead of changing the original string, string methods create a new string.

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

50

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

It might not be useful in every situation so we as developers need to create situations where the functions or methods we create/use are useful

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

A lot. . .

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

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

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

Booleans

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

If statements are used to create branching actions or decision making

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

Else is not required to use an if statement, but if the statement is false then the if statement will return undefined

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

If keyword, condition to check surrounded by parenthesis, curly brace to start code block for what to run if parameter is true, what to run if the parameter is true in the code block, closing curly brace

if (condition) {
statement
}

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

What are the three logical operators?

A

&& (and)
|| (or)
!(not)

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

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

A

You can use || for or, or && for and between the two expressions but keep both of them within the same ( ) parameter

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

The purpose of a loop is to repeat an action

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

The condition expression in a loop allows JavaScript to know when the loop should be stopped

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

An iteration is each time a loop is run. The first iteration would be the first time the loop is run and the last iteration is the final time a loop is run.

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

The condition expression is evaluated before executing the statement in 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?

A

The initialization expression of a for loop is evaluated once before the loop is begun

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

The condition expression of a for loop gets evaluated before every iteration

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

The final expression of a for loops gets evaluated at the end of each iteration

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

The break keyword can exit a loop before the condition expression evaluates to false

66
Q

What does the ++ increment operator do?

A

The ++ increment operator increases the value of the variable by 1

67
Q

How do you iterate through the keys of an object?

A

You use a for … in loop and set a variable for the keys

68
Q

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

A

The focus event

69
Q

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

A

The blur event

70
Q

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

A

The input event

71
Q

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

A

The submit event

72
Q

What does the event.preventDefault() method do?

A

It stops the form elements from returning to their default setting (either blank or placeholders)

73
Q

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

A

It refreshes the page

74
Q

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

A

The elements property

75
Q

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

A

The value property

76
Q

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

A

You run the risk of running into a bug and not knowing where in the code it happened

77
Q

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

A

You can check your progress and make sure everything is working the way you want it to

78
Q

What is the event.target?

A

The event.target is the property of the event object that holds the location of where the event occurred

79
Q

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

A

Display: none will hide all content inside of the element. The element is present but not showing any of its content

80
Q

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

A

Element.matches () takes a css selector in a string as its argument and returns a boolean

81
Q

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

A

You can use the element.getAttribute(‘attribute’)

82
Q

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

A

At every step ☺

83
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

We would need to put an event listener on each tab instead of on the container with the tabs inside of it

84
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

It would be written with a conditional for each tab we would need to check

85
Q

What is the event.target?

A

The event.target is the property of the event object that holds the location of where the event occurred

86
Q

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

A

Display: none will hide all content inside of the element. The element is present but not showing any of its content

87
Q

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

A

Element.matches () takes a css selector in a string as its argument and returns a boolean

88
Q

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

A

You can use the element.getAttribute(‘attribute’)

89
Q

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

A

At every step ☺

90
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

We would need to put an event listener on each tab instead of on the container with the tabs inside of it

91
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

It would be written with a conditional for each tab we would need to check

92
Q

What is a breakpoint in responsive Web design?

A

A breakpoint is a spot where the web page should change its styling. Often this is used for styling for different sized screens (mobile, tablet, or desktop)

93
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

Using a % allows the content to scale with the size of the page

94
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

Because of CSS cascade (source order) the “newest” ruleset (closest to the bottom) will be applied over previous rules

95
Q

What is JSON?

A

JSON (JavaScript Object Notation) is a way to store the contents of an object in a string most commonly used to transmit data to a web page

96
Q

What are serialization and deserialization?

A

Serialization is turning an object into date (stream of bytes)
Deserialization is turning that data (stream of bytes) back into the object

97
Q

Why are serialization and deserialization useful?

A

It turns complex data into data that is understood everywhere

98
Q

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

A

JSON.stringify(‘object’)

99
Q

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

A

JSON.parse(‘JSON string’);

100
Q

How do you store data in localStorage?

A

Use the setItem method on the localStorage object

localStorage.setItem(‘key’, ‘key value’)

101
Q

How do you retrieve data from localStorage?

A

Use the getItem method on the localStorage object

localStorage.getItem(‘key’)

102
Q

What data type can localStorage save in the browser?

A

Strings

103
Q

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

A

Right before the tab is about to unload (closing tab, closing window, refreshing tab. . . )

104
Q

What is a method?

A

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

105
Q

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

A

A method definition will have the function keyword and variable(s) for the parameter(s) whereas a method call will be called on an object with a . between the object and method and would have a variable for the argument (if an argument is needed)

Definition: methodName: function (parameter) {
}
Call: object.method(argument)

106
Q

Describe method definition syntax (structure).

A

Method definition will have the property the method is stored in (method name), colon, function keyword, parameter(s) in parenthesis, open curly brace for the function code block, code for the function to run, closing curly brace for the function code block

property: function (parameter) {
}

107
Q

Describe method call syntax (structure).

A

You use the object you want to call the method on, then a . followed by the method name and then the argument in parenthesis

object.method(argument)

108
Q

How is a method different from any other function?

A

Methods are functions that are properties of an object whereas functions can also exist outside of an object. These functions are called differently than methods

Method call - object.methodName(argument)
Function call - functionName(argument)

109
Q

What is the defining characteristic of Object-Oriented Programming?

A

Pairing data with behavior

110
Q

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

A

Abstraction
Encapsulation
Inheritance
Polymorphism

111
Q

What is “abstraction”?

A

Abstraction is the idea of using something complex but being thought of in a simple way

E.g. Turning on the light - to us is flipping a switch, to electricity it is opening a circuit connected to a break to move electricity to the lightbulb

112
Q

What does API stand for?

A

Application Programming Interface

113
Q

What is the purpose of an API?

A

Its purpose is to give programmers a way to interact with a system in a simplified, consistent fashion (using abstraction)

114
Q

What is this in JavaScript?

A

this is an implicit parameter that is checked/available at the time of a function call. It is used in methods when there is information in the same object that this wants to reference

115
Q

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

A

It means that this is available in a function even thought it was not declared or set as its own variable

116
Q

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

A

The value of this is determined when a function is called

117
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);
  }
};
A

this refers to nothing because nothing is being called and the value is determined at call time

118
Q
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();
A

The result of character.greet(); should be ‘It’s-a-me, Mario!

It pulls the value of this (which is the character object) at the firstName property which is Mario

119
Q
Given the above character object, what is the result of the following code snippet? Why?
var hello = character.greet;
hello();
A

this would be undefined because this would be called on the window object which does not have a firstName property

120
Q

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

A

You cannot tell the value before it is called

121
Q

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

A

Look for the object named to the left of the method call and look inside of the object, otherwise it is the window

122
Q

What kind of inheritance does the JavaScript programming language use?

A

Prototype-based inheritance (prototypal inheritance)

123
Q

What is a prototype in JavaScript?

A

A JavaScript prototype is simply an object that contains properties and (predominantly) methods that can be used by other objects.

124
Q

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

A

You can set an object as a prototype of another object allowing you to call the methods on those objects without them existing inside of the objects
There also prototypes already set on the objects (strings, arrays, and numbers)
Object.setPrototypeOf(object, prototype object);

125
Q

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

A

Inside of its prototypes

126
Q

What does the new operator do?

A

The new operator 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.

Creates a blank object

Points the newInstance’s prototype ot the constructor function’s prototype property

Executes constructor function with given arguments and stores as this

95%+ constructor function will not have a return statement which means that the newInstance gets returned instead

127
Q

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

A

The [[Prototype]] property

128
Q

What does the instanceof operator do?

A

The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object.

The return is a boolean value

129
Q

What is a “callback” function?

A

A callback function is a function that is passed as an argument to another function

130
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

You can use the setTimeout() window method

131
Q

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

A

By using the setInterval() window method

132
Q

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

A

0

This causes JavaScript to run the function as quickly as it can

133
Q

What do setTimeout() and setInterval() return?

A

They return a unique interval ID number that is needed to clear the recurring function

134
Q

What is AJAX?

A

Asynchronous JavaScript and XML is a way for users to send and update responses without having to update the page. The user can continue to do other things in the browser while waiting for the data to load.

135
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript and XML

136
Q

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

A

The new XMLHttpRequest(); object

137
Q

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

A

The load event

138
Q

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

A

They share a the same prototype

139
Q

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

A
  • A code block is the code within curly brackets { } that should run
  • Function code block, loop code block, condition code block
140
Q

What does block scope mean?

A
  • A variable when declared inside the if or switch conditions or inside for or while loops, are accessible within that particular condition or loop.
  • Tl;dr - variables declared inside of code blocks are only accessible inside those code blocks
141
Q

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

A

Blocked-scope

142
Q

What is the difference between let and const?

A
  • let is a block scope variable that can be updated but the updated value is only accessible inside of code block
  • const is a block scope constant variable and it’s value cannot be reassigned
143
Q

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

A

For the same reason we can update object property values, we can update the object’s property values but we cannot update the entire object (in this case, array)

144
Q

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

A

Can the value be updated and reused? - let

Should the value be constant? - const

145
Q

What is the syntax for writing a template literal?

A

You would surround the template literal with backticks `

146
Q

What is “string interpolation”?

A

String interpolation is the ability to substitute part of the string for the values of variables or expressions.

147
Q

What is destructuring, conceptually?

A

Object destructing is taking an object, and then turning that object’s properties into variables

148
Q

What is the syntax for Object destructuring?

A

const { object properties separated by a comma(use : and an alias to rename variables different from property name} = objectName

149
Q

What is the syntax for Array destructuring?

A

const [array indices separated by a comma] = arrayName

150
Q

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

A

The location of the assignment operator

  • An object destructured object will be the variable keyword, the object literal or properties being turned into variables, the assignment operator then the objects name
  • A normal object would be the variable keyword, object name, assignment operator, then the object literal
151
Q

What is the syntax for defining an arrow function?

A

Parameter (in parenthesis if more than one parameter or less than one parameter) => code to run

  • If it is one expression you do not need a code block or a return statement
  • But if a code block is used then a return statement is necessary
152
Q

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

A

It automatically returns the result of the expression

153
Q

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

A

It takes the value of the enclosing context to be the value of this

154
Q

What is the JavaScript Event Loop?

A

It is responsible for taking callbacks from the past view and then pushing them to the stack when the stack is clear

155
Q

What is different between “blocking” and “non-blocking” with respect to how code is executed?

A
  • Blocking code is currently running on the call stack

- Non-blocking code is an operation that is off of the call stack

156
Q

What are the three states a Promise can be in?

A

Pending - initial state - neither fulfilled or rejected
Fulfilled - operation was completed successfully
Rejected - operation has failed

157
Q

How do you handle the fulfillment of a Promise?

A

You can use the .then method on a promise to handle the fulfillment

158
Q

How do you handle the rejection of a Promise?

A

You can use the .catch method on a promise to handle the rejection

159
Q

What is Array.prototype.filter useful for?

A

It is useful for getting specific data out of arrays that you would want to use elsewhere

160
Q

What is Array.prototype.map useful for?

A

Map is useful for apply changes to all items in an array