JavaScript Flashcards

1
Q

[JS Primitives and Variables]

What is the purpose of variables?

A

store temporary bits of information such as strings or numbers for future use

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

[JS Primitives and Variables]

How do youdeclarea variable?

A

keywords let, const, var and variable name

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

[JS Primitives and Variables]

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

A

using the equals operator ( = )

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

[JS Primitives and Variables]

What characters are allowed in variable names?

A

alphabet letters, numbers, dollar sign ($) and underscore (_)

numbers cannot be used as the first character

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

[JS Primitives and Variables]

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

A

variable names have to be exactly the same, even capitalized letters

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

[JS Primitives and Variables]

What is the purpose of a string?

A

storing text which JS cannot read

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

[JS Primitives and Variables]

What is the purpose of a number?

A

for tasks involving counting or operations

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

[JS Primitives and Variables]

What is the purpose of a boolean?

A

for making decisions / choice (yes or no)

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

[JS Primitives and Variables]

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

[JS Primitives and Variables]

How do you update the value of a variable?

A

variableName = newValue;

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

[JS Primitives and Variables]

What is the difference betweennullandundefined?

A

null is a value that intentionally is nonexistent or invalid

undefined are variables that were not defined

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

[JS Primitives and Variables]

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

A

to know what is being logged and when the log was called

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

[JS Primitives and Variables]

Give five examples of JavaScript primitives.

A

string, number, boolean, null, undefined

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

[JS Operators and Expressions]

What data type is returned by an arithmetic operation?

A

number

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

[JS Operators and Expressions]

What is string concatenation?

A

Adding two strings together

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
[JS Operators and Expressions]
What purpose(s) does the + plus operator serve in JavaScript?
A

addition & concatenation

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

[JS Operators and Expressions]

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

A

true or false (boolean)

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

[JS Operators and Expressions]

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

A

it adds to the original value and assigns the sum as the value

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

What value is given when trying to multiple, divide or subtract two strings?

A

NaN (not a number)

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

[JS Objects]

What are objects used for?

A

for storing variables and functions (that have similarities)

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

[CSS Objects]

What are object properties?

A

bits of information as variables about an object

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

[CSS Objects]

Describe object literal notation.

A

var obj = {
property: value,
property: value
}

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

[CSS Objects]

How do you remove a property from an object?

A

delete object.property

delete object[‘property’]

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

[CSS Objects]

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

A

dot notation or bracket notation

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

[JS Arrays]

What are arrays used for?

A

Storing a list or set of variables related to each other.

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

[JS Arrays]

Describe array literal notation.

A

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

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

[JS Arrays]

How are arrays different from “plain” objects?

A

objects- have individually named properties and value pairs
arrays- have index number and values
objects don’t have an order

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

[JS Arrays]

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
29
Q

[JS Arrays]

What is the length property of an array?

A

shows how many pieces of data are in an array

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

[JS Arrays]

How do you calculate the last index of an array?

A

array.length - 1

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

[JS Functions]

What is a function in JavaScript?

A

repeatable block of code that does something when called

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

[JS Functions]

Describe the parts of a function definition.

A
function keyword
optional function name
parenthesis
optional parameters between parentheses
curly braces {}
return keyword within curly braces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

[JS Functions]

Describe the parts of a function call.

A

functionName (arguments)

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

[JS Functions]

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

A

A function definition tells JS what to do (without actually doing it). Contains keyword, parameters and code block.

A function call is simply asking JS to go through the function. Contains function name, arguments and parentheses.

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

[JS Functions]

What is the difference between a parameter and an argument?

A

Parameters are part of a definition.

Arguments are part of a function call.

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

[JS Functions]

Why are function parameters useful?

A

To show what information is needed for the function to work without having to rewrite a whole function for different arguments.

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

[JS Functions]

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

A
  1. It replaces the function call

2. Stops the function

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

[JS Methods]

Why do we log things to the console?

A

To check for desired outputs and that everything is working in the expected.

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

[JS Methods]

What is a 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
40
Q

[JS Methods]

How is a method different from any other function?

A

It is called on an object, not through a function name and parenthesis.

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

[JS Methods]

How do you remove the last element from an array?

A

array.pop();

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

[JS Methods]

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
43
Q

[JS Methods]

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
44
Q

[JS Methods]

How do you delete an element from an array?

A

array.splice(index, delAmount, item1, …);

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

[JS Methods]

How do you append an element to an array?

A

array.push();

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

[JS Methods]

How do you break a string up into an array?

A

string.split();

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

[JS Methods]

Do string methods change the original string?

A

No

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

[JS Methods]

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

A

No, their functionalities can be used to manipulate data without the use of the value returned.

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

[JS If statements]

Give 6 examples of comparison operators.

A
strictly equals ===
not strictly equal !==
greater than >
greater than or equals >=
less than <
less than or equals <=
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

[JS If statements]

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
51
Q

[JS If statements]

What is the purpose of an if statement?

A

allows the computer make a decision based on certain stated criteria

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

[JS If statements]

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
53
Q

[JS If statements]

Describe the syntax of an if statement.

A

if keyword
parenthesis with condition inside
curly brackets with code to run if true

if (condition) {
code to be executed
}

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

[JS If statements]

What are three logical operators?

A

or ||
and &&
not !

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

[JS If statements]

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

A

using the and logical operators and && or ||

example: (a == b && c ==d )

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

[JS Loops]

What is the purpose of a loop?

A

To repeat a block of code as necessary

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

[JS Loops]

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

A

Tells the loop when to stop running

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

[JS Loops]

What does iteration mean in the context of loops?

A

Single run of the loop’s code block

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

[JS Loops]

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

A

At the beginning of each iteration.

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

[JS Loops]

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

A

Once, before the first iteration.

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

[JS Loops]

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

A

After the initialization and before each iteration

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

[JS Loops]

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

A

After each iteration.

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

[JS Loops]
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?

A

break

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

[JS Loops]

What does the ++ increment operator do?

A

Increments and substitutes a variable

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

[JS Loops]

How do you iterate through the keys of an object?

A

for…in loop

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

[DOM Querying]

What is a ‘model’?

A

It’s a representation of elements

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

[DOM Querying]

Which ‘document’ is being referred to in the phrase Document Object Model?

A

the whole HTML page

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

[DOM Querying]

What is the word ‘object’ referring to in the phrase Document Object Model?

A

refers to the elements on the HTML page that are represented as objects

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

[DOM Querying]

What is a DOM Tree?

A

representative chunk of a page as objects

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

[DOM Querying]

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

A

getElementById();

querySelector();

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

[DOM Querying]

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
72
Q

[DOM Querying]

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

A

in order to reuse it instead of looking for it everytime you want to manipulate it

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

[DOM Querying]

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
74
Q

[DOM Querying]

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

A

So that the HTML elements are loaded first

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

[DOM Querying]

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

A

argument: string (css selector)

returns the HTML element

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

[DOM Querying]

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

A

argument: string (css selector)

returns a node list with all the HTML elements inside

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

[DOM Events]

What is the purpose of events and event handling?

A

fire actions for when users interact with a web page

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

[DOM Events]

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

A

No, some parameters are optional

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

[DOM Events]

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

A

addEventListener();

80
Q

[DOM Events]

What is a callback function?

A

a function passed into another function as an argument

81
Q

[DOM events]

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

A

an object with data about the event that occurred

82
Q

[DOM Events]

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

A

a target property of the event object storing the DOM element was where the event originated from

83
Q

[DOM Events]
What is the difference between these two snippets of code?
-element.addEventListener(‘click’, handleClick);
-element.addEventListener(‘click’, handleClick( ));

A

if the parenthesis is there, it would indicate that the function should run when the page loads

84
Q

[DOM Manipulation]

What is the className property of element objects?

A

gets or sets the class of an element

85
Q
[DOM Manipulation]
How do you update the CSS class attribute of an element using JavaScript?
A

element.className = ‘newClassName’;

86
Q

[DOM Manipulation]

What is the textContent property of element objects?

A

get what’s there or assign a new value

87
Q

[DOM Manipulation]

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

A

element.textContent = ‘text you want’;

88
Q

[DOM Manipulation]

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

A

no, when we already know all the elements we want to change

89
Q

[DOM Manipulation]

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

A

it’s easier to find and reuse in JavaScript

90
Q

[JS Forms]

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

A

focus

91
Q

[JS Forms]

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

A

blur

92
Q

[JS Forms]

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

A

input

93
Q

[JS Forms]

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

A

submit

94
Q

[JS Forms]

What does the event.preventDefault() method do?

A

it prevents the default behavior of an event

95
Q

[JS Forms]

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

A

refreshes the page

96
Q

[JS Forms]

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

A

elements property

97
Q

[JS Forms]

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

A

value property

98
Q

[DOM Creation]

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

A

No, creates an element but doesn’t insert it to the page

99
Q

[DOM Creation]

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

A

parent. appendChild(child);

element. append(multipleChildren);

100
Q

[DOM Creation]

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

A

2 strings

  • name of the attribute
  • attribute value
101
Q

[DOM Creation]

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

A

createElement()
createTextNode()
querySelect() a parent
appendChild() (to an element already on the page)

102
Q

[DOM Creation]

What is the textContent property of an element object for?

A

for adding or getting text from an element

103
Q
[DOM Creation]
Name two ways to set the class attribute of a DOM element.
A

.className

.setAttribute(‘class’, ‘className)

104
Q

[DOM Creation]

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

A

to use it repeatedly for many elements created saving time & work

105
Q

[CSS Media Queries]

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

A

min-width
max-width
min-height
max-height

106
Q

[CSS Media Queries]

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

A

viewport meta tag

107
Q

[DOM-event-delegation]

What is the event.target?

A

the HTML element from which the event originated from

108
Q

[DOM-event-delegation]

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

A

event bubbling

109
Q

[DOM-event-delegation]

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

A

event.target.tagName;

110
Q

[DOM-event-delegation]

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

A

takes a css selector and returns the nearest upward match to the selector (reverse querySelector)

111
Q

[DOM-event-delegation]

How can you remove an element from the DOM?

A

remove method

112
Q

[DOM-event-delegation]
If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?

A

add an event listener to the parent

avoid by matches or finding a className, or element type through tagName

113
Q

[JS View Swapping]

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

A

it removes it from the page layout (as if it didn’t exist)

114
Q

[JS View Swapping]

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

A

it takes a selector string as an argument

returns: true if matches
false: if doesn’t match

115
Q

[JS View Swapping]

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

A

element.getAttribute(‘attributeName’);

116
Q

[JS View Swapping]
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

add event listeners to each individual element

117
Q

[JS Custom Methods]

What is a method?

A

A function that is a property of an object.

118
Q

[JS Custom Methods]

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

A

a method definition contains parameters and the keyword function while a method call only contains the object that has the method and the property name of the function

119
Q

[JS Custom Methods]

Describe method definition syntax (structure).

A

inside of the object, give a property name and the value is a unnamed function.

120
Q

[JS Custom Methods]

Describe method call syntax (structure).

A

objectName.method(optional arguments);

121
Q

[JS Custom Methods]

How is a method different from any other function?

A

it can only be called with the object it’s in

122
Q

[JS Custom Methods]

What is the defining characteristic of Object-Oriented Programming?

A

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

123
Q

[JS Custom Methods]

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

A

Abstraction
Encapsulation
Inheritance
Polymorphism

124
Q

[JS Custom Methods]

What is “abstraction”?

A

Working with complex things in simpler ways by breaking them down.

125
Q

[JS Custom Methods]

What does API stand for?

A

Application programing interface

126
Q

[JS Custom Methods]

What is the purpose of an API?

A

For functionalities to be used or exchange information between different software more easily

127
Q

[JS this]

What is ‘this’ in JavaScript?

A

Refers to the object that is calling a method. By default it’s the window

128
Q

[JS this]

What does it mean to say that ‘this’ is an implicit parameter?

A

It’s a parameter that is available even though it’s never included in the parameter list or declared.

129
Q

[JS this]

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

A

call time

130
Q

[JS this]

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

A

we can’t know

131
Q

[JS this]

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

A

look at the object that is calling the method (left to the dot)

132
Q

[JS Prototypes]

What kind of inheritance does the JavaScript programming language use?

A

Prototypal-inheritance

133
Q

[JS Prototypes]

What is a prototype in JavaScript?

A

An object that is a prototype for other objects that can access the prototype’s methods or information.

134
Q

[JS Prototypes]
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

through prototypal inheritance

135
Q

[JS Prototypes]

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

A

in the prototype

136
Q

[JS Constructors]

What does the new operator do?

A
  • creates a blank plain JS object
  • points the new object’s prototype to the constructors functions’ prototype property
  • ‘this’ in the object now refers to the new object
  • the new object created is returned
137
Q

[JS Constructors]

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

A

prototype property

138
Q

[JS Constructors]

What does the ‘instanceof’ operator do?

A

checks if a variable (objects) is a instance of a constructor function

139
Q

[JS Timers]

What is a ‘callback’ function?

A

a function passed as another function’s argument

140
Q

[JS timers]
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

setTimeout()

141
Q

[JS Timers]

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

A

setInterval();

142
Q

[JS Timers]

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

A

no delay - 0ms

143
Q

[JS Timers]

What do setTimeout() and setInterval() return?

A

a numeric ID to be used as an argument in the clearInterval() function

144
Q

[HTTP Messages]

What is a client?

A

a program requesting data (service request)

145
Q

[HTTP Messages]

What is a server?

A

the one that provides service

146
Q

[HTTP Messages]

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

A

GET

147
Q

[HTTP Messages]

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

A

an HTTP method (get, put, post, head or options)
a request target (URL or absolute path)
HTTP version

148
Q

[HTTP Messages]

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

A

protocol version
status code
status text

149
Q

[HTTP Messages]

What are HTTP headers for?

A

meta-data for describing a document in key-value pairs

150
Q

[HTTP Messages]

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

A

Not required

151
Q

[JS AJAX]

What is AJAX?

A

Technologies that offer asynchronous functionality to the browser, loading parts of a page without having to reload the whole page.

152
Q

[JS AJAX]

What does the AJAX acronym stand for?

A

Asynchronous JavaScript and XML

153
Q

[JS AJAX]
Which object is built into the browser for making HTTP requests in JavaScript? And what are the three parameters for open()?

A

XMLHttpRequest object

  • HTTP method
  • URL of page that will handle the request
  • Boolean for if it should be asynchronous
154
Q

[JS AJAX]

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

A

load event

155
Q

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

A

prototypal inheritance

156
Q

[const & let]

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

A

Code block is a part of code that does something for example the code between curly braces in functions, if statements, and loops.

157
Q

[const & let]

What does block scope mean?

A

Everything that happens inside a code block which is not accessible outside of the codeblock.

158
Q

[const & let]

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

A

code block scope

159
Q

[const & let]

What is the difference between ‘let’ and ‘const’?

A

const cannot be reassigned

let can be reassign

160
Q

[const & let]

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

A

The contents of the array is being updated but not the value of the const variable

161
Q

[const & let]

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

A

If you want to change the variable or not in the future

162
Q

[ES6 Template Literals]

What is the syntax for writing a template literal?

A

backticks for start and end
dollar sign and curly braces for expressions

${}

163
Q

[ES6 Template Literals]

What is ‘string interpolation’?

A

the ability to substitute part of the string for the values of variables or expressions

164
Q

[ES6 Destructuring]

What is destructuring, conceptually?

A

Take objects or arrays and creates variables based on an object’s properties or an array’s elements.

165
Q

[ES6 Destructuring]

What is the syntax for ‘Object’ destructuring?

A

const {property : newVarName} = objOriginName

variable keyword, open curly brace, property to be retrieved, optional: new variable name, optional: with comma property sequence, equals sign, object from which to get data from

166
Q

[ES6 Destructuring]

What is the syntax for ‘Array’ destructuring?

A

const [ element : newVarName ] = originalArray
variable keyword, square brackets, element name, colon, new variable name at correct position, optional sequence for other elements or empty commas (ORDER MATTERS), equals sign, original array

167
Q

[ES6 Destructuring]

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

A

square brackets for array and curly brackets for objects on the LEFT of the equals sign

168
Q

[ES6 Arrow Functions]

What is the syntax for defining an arrow function?

A

(parameters) => {statement or expression};

169
Q

[ES6 Arrow Functions]

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

A

the function returns the result of that single expression

170
Q

[ES6 Arrow Functions]

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

A

it doesn’t bind; this is from the outer scope of the arrow function
ES6 arrow function: this is defined in function definition
ES5: this is defined when called

171
Q

What is the difference between the web and the internet?

A

Web -> HTTP and URLs (navigation from page to page)

Internet is the network -> TCPIP (transmission control protocol/internet protocol)

172
Q

[ES6 Promises]

What are the three states a Promise can be in?

A

pending
fulfilled
rejected

173
Q

[ES6 Promises]

How do you handle the fulfillment of a Promise?

A

promise.then(callback)

174
Q

[ES6 Promises]

How do you handle the rejection of a Promise?

A

promise.catch(callback)

175
Q

[Array Filter]

What is Array.prototype.filter useful for?

A

creating a new array while excluding certain elements

176
Q

[Array Map]

What is Array.prototype.map useful for?

A

manipulating and transforming elements inside an array

177
Q

[ES6 Classes]

What is “syntactic sugar”?

A

Something that doesn’t add anything new but is easier to read.

178
Q

[ES6 Classes]

What is the typeof an ES6 class?

A

function

179
Q
[ES6 Classes]
Describe ES6 class syntax.
A
class ClassName {
        constructor(name) {
               this.name = name;
        }
        method(){
                return this.name;
         }
}
180
Q

[ES6 Classes]

What is ‘refactoring’?

A

restructuring existing code without changing it’s behavior

181
Q

[ES6 Modules]

How are ES Modules different from CommonJS modules?

A
ES Modules uses import instead of require()
ES Modules uses export instead of module object

ES Modules are officially part of ECMAScript standard

182
Q

[ES6 Modules]

What kind of modules can Webpack support?

A

CommonJS, ECMAScript, AMD

183
Q

[fetch]

What does ‘fetch()’ return?

A

a promise object that resolves with a response object

184
Q

[fetch]

What is the default request method used by ‘fetch()’?

A

GET

185
Q

[fetch]

How do you specify the request method (GET, POST, etc.) when calling ‘fetch’?

A

fetch with a request option (object after the path) which determines the method

const response = fetch(url, { method: ‘POST’ })

186
Q

[Data Structures]

What does the acronym LIFO mean?

A

last-in-first-out

187
Q

[Data Structures]

What methods are available on a stack data-structure?

A

push and pop, sometimes peek

188
Q

[Data Structures]

What must you do to access the value at an arbitrary point in a stack (not just the top)?

A

remove items from the stack one by one

189
Q

[Data Structures]

What does the acronym FIFO mean?

A

first-in-first-out

190
Q

[Data Structures]

What methods are available on a Queue data structure?

A

enqueue- adds value to back of queue

dequeue- removes value from front of queue

191
Q

[Data Structure]

What must you do to access the value at an arbitrary point in a queue?

A

dequeue until arriving at point

192
Q

[Data Structures]

How are linked lists different from an array?

A

Linked lists are sequential access (cannot grab values from the middle whenever).

193
Q

[Data Structures]

How would you access an arbitrary node in a linked list (not just the ‘head’)?

A

Traverse node by node

194
Q
[JS Closures]
What must the return value of myFunction be if the following expression is possible?
// myFunction( )( );
A

myFunction is being called and it’s return is being called

I can assume the return of myFunction is a function

195
Q
[JS Closures]
What does this code do?
// const wrap = value => () => value;
A

variable wrap is a function that takes a value and returns a function that returns value

196
Q

[JS Closures]

In JavaScript, when is a function’s scope determined; when it is called or when it is defined?

A

defined

197
Q

[JS Closures]

What allows JavaScript functions to ‘remember’ values from their surroundings?

A

Closures