JavaScript Flashcards

1
Q

What is the purpose of variables?

A

to store information

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

How do you declare a variable?

A

var 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

=

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 number _ $

cannot start with a number

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

letters have to match so the comp understands

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

to store word or sentences

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

to store numbers

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

What is the purpose of a boolean?

A

true or false

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

What does the = operator mean in JavaScript?

A

assigned

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

the var name and assignment op then the new value

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

What is the difference between null and undefined?

A

null means nothing. undefined means a variable has been declared but not defined yet.

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

to help with debugging and to see what your console is logging

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

Give five examples of JavaScript primitives.

A

undefined , null , boolean , string and number

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

to combine strings together

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

adds values together

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

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

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 on the right, to the variable on the left, and then assigns that value back into the variable on the left.

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

What are objects used for?

A

to holds multiple values..

they are used to model real world objects

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

What are object properties?

A

a property is an association between a name (or key) and a value. A property’s value can be a function, in which case the property is known as a method

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

Describe object literal notation.

A
var example = {
}
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 keyword

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

bracket or dot notation

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

What are arrays used for?

A

lets you store multiple values in a single variable.

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

Describe array literal notation.

A

var example = []

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 stores list

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

to see how many items are 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

array.length - 1

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

What is a function in JavaScript?

A

a set of statements that performs a task or calculates a value

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
function functionName(parameter) {
}
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

function name(argument)

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 has to have the keyword and { }

call is just name and ()

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

Why are function parameters useful?

A

allows us to store data in it

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

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

A

ends function execution and specifies a value to be returned

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

Why do we log things to the console?

A

to see if its working proper, debugging

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

What is a method?

A

methods are actions that can be performed on objects.

a function on a obj

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

How is a method different from any other function?

A

a method is associated with an object

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

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

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

A

floor() Method of math obj

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

How do you generate a random number?

A

random() of math obj

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

How do you delete an element from an array?

A

array.splice()

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

How do you append an element to an array?

A

push() and unshift() Method

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

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

A

no return a new string. to check console.log()

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

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

A

30

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

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

A

no

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

Give 6 examples of comparison operators.

A

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

Strictly equal, Strictly unequal, less than, greater than, less than or equal to , greater than or equal to

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

What is the purpose of an if statement?

A

to evaluate or check a condition, to make a decision

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

Describe the syntax (structure) of an if statement.

A

if () {

}

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

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

A

with a logical operator

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

What is the purpose of a loop?

A

to do something repeatedly and as quickly as possible

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

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

A

to see if the code should run again

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

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

A

the number of times it iterates

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

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

A

Runs before the first execution on the loop

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

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

A

it is the first thing ran

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

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

A

Expression that is run after every iteration

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

What does the ++ increment operator do?

A

adds 1

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

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

What does the ++ increment operator do?

A

adds 1, assigns the new value to the original

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

How do you iterate through the keys of an object?

A

for in loop

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

Why do we log things to the console?

A

seeing the data and for debugging

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

What is a “model”?

A

a representation of something

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

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

A

document node

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

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

A

different parts of the page loaded in the browser

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

What is a DOM Tree?

A

all the pieces of the dom

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

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

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

A

getElementByClassName

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

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

A

reduces the amount of times to query the dom

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

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

A

because the broswer needs to analyze all the html before the js

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

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

A

takes a vaild css selector

its returns An HTML Element object representing the first element in the document that matches the specified set of CSS selectors,

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

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

A

takes a vaild css selector

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

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

Why do we log things to the console?

A

seeing the data and for debugging

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

What is the purpose of events and event handling?

A

to have different interactions

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

What do [] square brackets mean in function and method syntax documentation?

A

that its optional

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

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

A

addEventListener

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

What is a callback function?

A

a function passed into another function as an argument

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

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

A

the event object

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

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

A

event.target tells where the event started. check in the console.log, more info in mdn web docs

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

What is the difference between these two snippets of code?

A

with the parentheses the function would run as the

page loads, instead of when the event fires

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

What is the className property of element objects?

A

sets the value of the class attribute of the specified element.

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

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

A

example.className =

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

What is the textContent property of element objects?

A

allows us to get or set the text content

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

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

A

example.textContent =

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

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

A

no

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

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

A

more complicated!

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

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

A

alot more control in variables

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

What is the event.target?

A

to target of the element that you interacted with

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

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

A

event bubbling

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

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

A

tagName

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

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

A

takes selectors as the argument and returns the closest ancestor of the selected element

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

How can you remove an element from the DOM?

A

node.remove();

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

put the listener on the parent

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

What is the event.target?

A

to target of the element that you interacted with

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

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

A

its hides that element

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

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

A

takes a selector and returns a boolean

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

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

A

getAttribute()

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

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

A

all the time

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

event listeners for each tab and callback functions for those

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

would have to manually do the checks

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

What is JSON?

A

json is a text-based data format following JavaScript object syntax. it allows different systems to exchange data

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

What are serialization and deserialization?

A

Serialization is turning an object into a stream of bytes so you can send it over the network.

Deserialization getting a stream of bytes and turning it into a obj

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

Why are serialization and deserialization useful?

A

allows us to commutate from different clients

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

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

A

JSON.stringify()

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

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

A

JSON.parse()

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

How to you store data in localStorage?

A

localStorage.setItem

112
Q

How to you retrieve data from localStorage?

A

localStorage.getItem

113
Q

What data type can localStorage save in the browser?

A

JSON string data

114
Q

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

A

before everything is unloaded

115
Q

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

A

a group of instructions. example if and for statements

116
Q

What does block scope mean?

A

variables exist only within the corresponding block.

117
Q

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

A

block scope

118
Q

What is the difference between let and const?

A

const cant change and let you can have a new value

119
Q

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

A

you’re not re-assigning or re-declaring

120
Q

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

A

use const for everything if you cant use let

121
Q

What is destructuring, conceptually?

A

short hand for accessing values quickly

122
Q

What is the syntax for Object destructuring?

A

const { } = object

123
Q

What is the syntax for Array destructuring?

A

const [ ] = array

124
Q

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

A

the location of the assignment operator

125
Q

What is the syntax for writing a template literal?

A

let or const name = backtick ${variable} backtick;

126
Q

What is “string interpolation”?

A

is replacing placeholders with values in a string literal

127
Q

What is a method?

A

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

128
Q

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

A

definition write outs the code block and the call actual uses it.

129
Q

Describe method definition syntax (structure).

A
{
  example: function(param1, param2, …) {
    // function body
  }
};
130
Q

Describe method call syntax (structure).

A

object.example(arg1, arg2, …)

object‘example’

131
Q

How is a method different from any other function?

A

it is a property of a object

132
Q

What is the defining characteristic of Object-Oriented Programming?

A

encapsulation, grouping everything together in one place

133
Q

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

A

Abstraction, Encapsulation, Inheritance, Polymorphism

134
Q

What is “abstraction”?

A

simplifying complicated things

135
Q

What does API stand for?

A

application programming interface

136
Q

What is the purpose of an API?

A

allows developers to create complex functionality more easily. allows apps to interact with eachother

137
Q

What is this in JavaScript?

A

represents the scope of the object or whatever its in

138
Q

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

A

meaning 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

139
Q

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

A

call time

140
Q

What does this refer to in the following code snippet?

A

character object

141
Q

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

A

It’s-a-me, mario!

142
Q

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

A

It’s-a-me, undefined !,

143
Q

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

A

you cant tell what its going to be

144
Q

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

A

you dont know forsure because it can be changed

145
Q

What kind of inheritance does the JavaScript programming language use?

A

In JavaScript, inheritance is supported by using prototype object.

prototypal inheritance

146
Q

What is a prototype in JavaScript?

A

The prototype is an object that is associated with every functions and objects by default in JavaScript

147
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

it inherited the method to the prototype

148
Q

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

A

it looks at it prototype

149
Q

What is a client?

A

a computer or a program that relies on sending a request to another program, hardware or software that accesses a service made available by a server

150
Q

What is a server?

A

a hardware or software that provides functionality for other programs or devices

151
Q

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

A

GET

152
Q

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

A

HTTP method, the request target and HTTP version

153
Q

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

A

The protocol version, A status code, and a status text

154
Q

What are HTTP headers?

A

HTTP headers let the client and the server pass additional information with an HTTP request or response

155
Q

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

A

MDN web docs

156
Q

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

A

no

157
Q

What is AJAX?

A

Ajax allows you to request
data from a server and
load it without having to
refresh the entire page

it is the use of the XMLHttpRequest object to communicate with servers. It can send and receive information in various formats, including JSON, XML, HTML, and text files

158
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript And XML

159
Q

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

A

XMLHttpRequest

160
Q

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

A

load

161
Q

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

A

they both inherent from event target

162
Q

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a web browser. Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.

163
Q

What can Node.js be used for?

A

It is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform

164
Q

What is a REPL?

A

Read–eval–print loop

165
Q

When was Node.js created?

A

May 27, 2009

166
Q

What back end languages have you heard of?

A

php , python, java

167
Q

What is a JavaScript module?

A

a single .js file

168
Q

What values are passed into a Node.js module’s local scope?

A

its pulls the raw files and puts into a file

169
Q

Give two examples of truly global variables in a Node.js program.

A

class abortcontrol , setTimeout , setInterval

170
Q

What is the purpose of module.exports in a Node.js module?

A

it tells Node.js which code to “export” from a file so other files are allowed to access the exported code.

171
Q

How do you import functionality into a Node.js module from another Node.js module?

A

require()

172
Q

What is the JavaScript Event Loop?

A

its responsible for executing the code, collecting and processing events, and executing queued sub-tasks

173
Q

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

A

Blocking block operations until that operation finishes and non-blocking doesn’t prevent other things from happening.

174
Q

What is a computer process?

A

computer program that is being executed by one or many threads

175
Q

Roughly how many computer processes are running on your host operating system

A

155

176
Q

Why should a full stack Web developer know that computer processes exist?

A

to see if the server is still running and to kill the process

177
Q

What is the process object in a Node.js program?

A

a global that provides information about, and control over, the current Node.js process

178
Q

How do you access the process object in a Node.js program?

A

console.log

179
Q

What is the data type of process.argv in Node.js?

A

array

180
Q

What is NPM?

A

packaging manager, share library code

developers use npm to share and borrow packages, and many organizations use npm to manage private development as well.

181
Q

What is a package?

A

Node modules, or contain Node modules

to store a bunch of code into one chunk

182
Q

How can you create a package.json with npm?

A

npm init

183
Q

What is a dependency and how to you add one to a package?

A

source code you didn’t write but it depends on it

Packages required by your application in production.

npm install

184
Q

What happens when you add a dependency to a package with npm?

A

that package gets installed into node_modules

185
Q

How do you add express to your package dependencies?

A

npm install express

186
Q

What Express application method starts the server and binds it to a network PORT?

A

listen()

187
Q

How do you mount a middleware with an Express application?

A

.use()

188
Q

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

application/json
application/javascript
text/html
text/css

189
Q

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

A

‘focus’

190
Q

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

A

‘blur’

191
Q

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

A

‘input’

192
Q

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

A

submit

193
Q

What does the event.preventDefault() method do?

A

method cancels the event if it is cancelable, meaning that the default action that belongs to the event will not occur.

194
Q

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

A

it doesnt save

195
Q

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

A

elements property

196
Q

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

A

value property

197
Q

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

A

you dont know if it works

198
Q

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

A

you can see if theres any error

199
Q

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

A

no

200
Q

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

A

appendchild()

201
Q

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

A

first the attribute then the value

202
Q

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

A

createElement
textNode
appendChild

203
Q

What is the textContent property of an element object for?

A

to set the element’s text content

204
Q

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

A

setAttribute and .className

205
Q

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

A

its reusable

206
Q

What does the new operator do?

A

Creates a blank, plain JavaScript object.

Adds a property to the new object (__proto__) that links to the constructor function’s prototype object

Binds the newly created object instance as the this context

Returns this if the function doesn’t return an object.

207
Q

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

A

prototype property

208
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.

209
Q

What is a “callback” function?

A

a function passed into another function as an argument to perform a action

210
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

setTimeout()

211
Q

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

A

setInterval()

212
Q

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

A

0

213
Q

What do setTimeout() and setInterval() return?

A

a timer id

214
Q

What is a CLI?

A

command-line interfaces.

215
Q

What is a GUI?

A

graphical user interface

216
Q

What are the three virtues of a great programmer?

A

laziness, impatience, and hubris

217
Q

What is a JavaScript module?

A

a file

218
Q

What values are passed into a Node.js module’s local scope?

A

exports, require, module, __filename, and __dirname

219
Q

Give two examples of truly global variables in a Node.js program.

A

process , settimeout

220
Q

What is the purpose of module.exports in a Node.js module?

A

Module exports are the instruction that tells Node.js which bits of code (functions, objects, strings, etc.) to “export” from a given file so other files are allowed to access the exported code

221
Q

How do you import functionality into a Node.js module from another Node.js module?

A

require()

222
Q

What is a directory?

A

a collection of files typically created for organizational purposes.

223
Q

What is a relative file path?

A

Relative paths do not start with / and point to a location relative to the document that the path reference is made in.

224
Q

What is an absolute file path?

A

Absolute paths start with / and point to the root of your site. A URL is a prime example of an absolute path.

225
Q

What module does Node.js include for manipulating the file system?

A

FS

226
Q

What method is available in the Node.js fs module for writing data to a file?

A

fs.writeFile

227
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous

228
Q

What does the express.json() middleware do and when would you need it?

A

middleware will json parse it

229
Q

What are the three states a Promise can be in?

A

pending
fulfilled
rejected

230
Q

How do you handle the fulfillment of a Promise?

A

.then

231
Q

How do you handle the rejection of a Promise?

A

.catch

232
Q

What is Array.prototype.filter useful for?

A

working with a filter subset of data

good with quick search

233
Q

What is Array.prototype.map useful for?

A

to simplify your code.

to take raw data and format it.

Extracting values from an array of object.

234
Q

What is Array.prototype.reduce useful for?

A

to take a array of values and reduce it to a single value

get a single value

235
Q

What is “syntactic sugar”?

A

syntax within a programming language that is designed to make things easier to read or to express. It makes the language “sweeter” for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer.

236
Q

What is the typeof an ES6 class?

A

obj

237
Q

Describe ES6 class syntax.

A
class name {
  constructor(x, y) {
    this
  }
}
238
Q

What is “refactoring”?

A

is the process of restructuring existing computer code—changing the factoring—without changing its external behavior.

239
Q

What is Webpack?

A

It’s a tool that lets you bundle your JavaScript applications

240
Q

How do you add a devDependency to a package?

A

–save-dev

241
Q

What is an NPM script?

A

An npm script is a convenient way to bundle common shell commands for your project. They are typically commands, or a string of commands, which would normally be entered at the command line in order to do something with your application. Scripts are stored in a project’s package

242
Q

How do you execute Webpack with npm run?

A

npm run build

243
Q

What is React?

A

React is a JavaScript library for creating user interfaces

244
Q

What is a React element?

A

An element is a plain object describing a component instance or DOM node and its desired properties

245
Q

How do you mount a React element to the DOM?

A

ReactDOM.render()

246
Q

What is Babel?

A

toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments

247
Q

What is a Plug-in?

A

a software component that adds a specific feature to an existing computer program.

248
Q

What is a Webpack loader?

A

They allow you to pre-process files as you import or “load” them

249
Q

How can you make Babel and Webpack work together?

A

Babel Loader

250
Q

What is JSX?

A

JavaScript XML is a form of markup that allows us to write HTML in React by converting HTML tags into React elements.

251
Q

Why must the React object be imported when authoring JSX in a module?

A

it will be undefined and the createElement call will fail.

252
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

@babel/plugin-transform-react-jsx

253
Q

What is a React component?

A

JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

describes a piece of our UI

254
Q

How do you define a function component in React?

A

must start with cap letter

255
Q

How do you mount a component to the DOM?

A

ReactDOM.render

256
Q

What are props in React?

A

properties

arguments passed into components

257
Q

How do you pass props to a component?

A

key value pairs

use the prop name and a value

258
Q

How do you write JavaScript expressions in JSX?

A

inside curly braces

259
Q

How do you create “class” component in React?

A

class Example extends React.Component

260
Q

How do you access props in a class component?

A

this.props

261
Q

What is the purpose of state in React?

A

to update the element, gives us control over the component

262
Q

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

A

onClick={this.handleClick}

do it as a attribute

263
Q

What are controlled components?

A

An input form element whose value is controlled by React

264
Q

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

A

a value and an onChange

265
Q

What Array method is commonly used to create a list of React elements?

A

map

266
Q

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

A

IDs from your data as keys

makes react do less work for the same outcome

267
Q

What does express.static() return?

A

exposes a directory or a file to a particular URL so it’s contents can be publicly accessed.

returns a function

268
Q

What is the local __dirname variable in a Node.js module?

A

The directory name of the current module

absolute path

269
Q

What does the join() method of Node’s path module do?

A

Joins several segments into one path

270
Q

What does fetch() return?

A

a Promise that you can use to retrieve the response of the request.

271
Q

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

A

GET

272
Q

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

A

method: “POST” or whatever you need

273
Q

When does React call a component’s componentDidMount method?

A

invoked immediately after a component is mounted

274
Q

Name three React.Component lifecycle methods.

A

constructor, render, componentdidupdate

275
Q

How do you pass data to a child component?

A

props