JavaScript Flashcards

1
Q

What is the purpose of variables?

A

To store 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

variable key word let var or const and variable name operator then value

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

assignment operator value

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
must begin with letter, $, _
cannot use (.) or dash. cannot use key words reserved for words.  All variables are case sensitive. Bad practice to use same name using different cases.
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 has to match; and you use camelcase to make sure that is the case

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

store and manipulate text

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

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

Booleans are helpful when
determining which part of a
script should run.

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

What does the = operator mean in JavaScript?

A

it assigns a value

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 don’t need to use the variable keyword you use the variable name.

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 is a non-existent or invalid object or address.

whereas undefined has been just assigned

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

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

A

It describes the variable that is being entered and if you don’t put it it can be very confusing when reading your logs.

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

Give five examples of JavaScript primitives.

A

null, string, bigint, boolean, undefined, symbol and null

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

Number

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

What is string concatenation?

A

Process of joining together two or more strings to create one new string

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

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

A

to perform addition or string concatenation

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

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 is an expression

A

Junk of work that JavaScript needs to do

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

What are objects used for?

A

THere used to group together a set of variables and functions.

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

What are object properties?

A

it is a variable that is now a part of the object

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

Describe object literal notation.

A

variable object = { key: value}

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

How do you remove a property from an object?

A

you use the key word delete and then use dot notation to identify the property or method you want to remove from the object.

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

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

A

use dot notation or square brackets

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

What are arrays used for?

A

to store data thats in a list format

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

Describe array literal notation.

A

var variable = [ ‘ ‘ ]

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

How are arrays different from “plain” objects?

A

objects are collection of data with individual set of data. arrays are lists with set format or list.

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

What is the length property of an array?

A

amount of items in an array

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

What is a function in JavaScript?

A

Functions allow you to package up code for use later in your program. Block of code written to perform a task repeatably.

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

Describe the parts of a function definition.

A
Function definitions are made of:
the function keyword
an optional name
zero or more parameters
a code block
an optional return statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Describe the parts of a function call.

A

Functions are called with () parentheses and passed zero or more arguments.

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

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

A

Functions are called with () parentheses and passed zero or more arguments.
When a function is called, the parameters in its definition take on the values of the arguments that were passed.

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

What is the difference between a parameter and an argument?

A

When a function is called, the parameters in its definition take on the values of the arguments that were passed.

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

Why are function parameters useful?

A

A function can take parameters which are just values you supply to the function so that the function can do something utilising those values

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

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

A

it exits the functions code block. And can return values

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

Why do we log things to the console?

A

To see what the code we are writing is doing.

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

What is a method?

A

function stored in a property in an object

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

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

A

math.floor

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

How do you generate a random number?

A

math.random * number

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

How do you delete an element from an array?

A

splice.method

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

How do you append an element to an array?

A

push method

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

How do you break a string up into an array?

A

str.split()

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

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

A

do not change original string. could console or look via documentation.

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

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

A

20ish

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

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

A

No, it could be just a placeholder for data that you want to collect further down the road

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

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

A

50ish

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

Give 6 examples of comparison operators.

A

==, !=, ===(strict equal) !===(strict not equal) > < >= <=

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

What data type do comparison expressions evaluate to?

A

boolean

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

What is the purpose of an if statement?

A

Evaluates or checks a condition in order to execute a subsequent code block.

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

Describe the syntax (structure) of an if statement.

A

{
if (operand 1) comparison operator (operand 2)
}

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

What are the three logical operators?

A

&& || !

logical and, logical or, logical not

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

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

A

logical operators

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

What is the purpose of a loop?

A

Is to continuously run a bit of code until all conditions are met.

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

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

A

It allows the loop to end if it is false

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

what does iteration mean

A

it means that it is being ran through x many times

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

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

A

It gets ran through first

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

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

A

It gets ran through first

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

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

A

after it goes through the initialization

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

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

A

after the condition has been ran through and the block underneath has been ran through as well

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

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

What does the ++ increment operator do?

A

it increases the count by 1

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

How do you iterate through the keys of an object?

A

you use a for in loop

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

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

A

focus

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

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

A

blur

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

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

A

change

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

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

A

input

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

What does the event.preventDefault() method do?

A

IT clears the data from the inputs after the browser reloads

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

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

A

It continues to reload with the values still in the inputs

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

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

A

Elements

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

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

A

type

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

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

A

It allows you to see if you are messing up or if the code is acting the way that you want it to.

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

What is JSON?

A

Javascript Object Notation it is a way to pass information between networks. String containing javascript syntax

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

What are serialization and deserialization?

A

Serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network.

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

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

Why are serialization and deserialization useful?

A

converting objects into bytes and then converting them back into objects allows for things to be sent over the network. Allows you to get data later on.

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

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

A

using JSON Parse

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

How do you store data in localStorage?

A

storage.setitem()

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

How do you retrieve data from localStorage?

A

storage.getItem()

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

What data type can localStorage save in the browser?

A

string

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

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

A

When the window document and it’s resources are about to be unloaded. The document is still visible at this point however.

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

What is a method?

A

It is a function which is a property of an object.

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

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

A

There is no function code block in the method call

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

Describe method definition syntax (structure).

A

function definition

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

Describe method call syntax (structure).

A

object.method()

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

How is a method different from any other function?

A

It’s not any different. A method is associated with an object while a function is not.

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

What is the defining characteristic of Object-Oriented Programming?

A

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

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

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

A

Abstraction, Encapsulation, inheritance, polymorphism

94
Q

What is “abstraction”?

A

Being able to work with complex things in simple ways

95
Q

What does API stand for?

A

Application programming interface

96
Q

What is the purpose of an API?

A

is to give programmers a way to interact with a system in a simplified consistent fashion aka abstraction.

97
Q

What is this in JavaScript?

A

It is referring to the object you are in.

98
Q

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

A

It is available in a functions code block even though it was never included in the functions parameter list or declared with a variable

99
Q

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

A

it is determined when a function is called

100
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 means nothing until it is called

101
Q

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

A

character.greet();

It’s-a-me a Mario!

102
Q

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

A

You can’t

103
Q

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

A

name of the object that you are in.

104
Q

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

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

hello it’s a me undefined!

105
Q

What kind of inheritance does the JavaScript programming language use?

A

prototypal inheritance

106
Q

What is a prototype in JavaScript?

A

It is an object that contains properties and methods that can be used by other objects. Has to be told that the first object is a prototype.

107
Q

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

A

They use the methods that are found on the prototype method

108
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 is looking at the prototype object

109
Q

What does the new operator do?

A

lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.
creates a blank plain JS object, adds a new object with __proto__

110
Q

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

A

__proto_

111
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 is a boolean

112
Q

What is a “callback” function?

A

A callback function is a function that is passed into another function as an argument which is then invoked inside the outer function to complete some kind of routine or action.

113
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

use the setTimeout function

114
Q

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

A

Set Interval function

115
Q

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

A

a value of 0 is used. so Immediately or the next event cycle.

116
Q

What do setTimeout() and setInterval() return?

A

The return is a timeoutID

117
Q

What is AJAX?

A

IT is a programming practice of building dynamic webpages using a technology know as XMLHttpRequests
update the DOM and HTML without the need for a page refresh.

118
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript and XML but is now just a group of technologies that offer asynchronous functionality in the browser

119
Q

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

A

xmlhttpRequest object

120
Q

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

A

load events are fired

121
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

Because XMLHttpRequest object is a constructor object so they both share functionality via prototypal inheritance

122
Q

new XMLHttpRequest()

A

creates a new XHR object

123
Q

xhr.open()

A

to set the request method and url

124
Q

xhr.responseType

A

to automatically parse the JSON body into JavaScript Objects

125
Q

xhr.addEventListener()

A

to execute a function when the response is eventually loaded

126
Q

xhr.send()

A

to actually send the request to the server at the URL specified in xhr.open()

127
Q

xhr.status

A

to read the HTTP status code of the response message

128
Q

xhr.response

A

to get the body of the HTTP response once it has been converted from a JSON string toJavaScript objects.

129
Q

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

A

Code block is just grouped together/ code inside curly braces. functions definitions and conditional statements all have code blocks

130
Q

What does block scope mean?

A

are variables who only exist within the corresponding block that they were declared… difference is function is function scoped.

131
Q

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

A

they are both block scoped where var is function scoped

132
Q

What is the difference between let and const?

A

let can be updated but not redeclared. Const is constant it cannot be update nor can it be redeclared.

133
Q

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

A

because the array naming is immutable the values are mutable

134
Q

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

A

if something is going to be constant (none changing) then use const. If you want to reassign a certain value than you should declare it with the variable let

135
Q

What is the syntax for writing a template literal?

A

put them in backticks like this ${Expression}

136
Q

What is “string interpolation”?

A

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

137
Q

What is destructuring, conceptually?

A

makes it possible to unpack properties from objects and values from arrays into distinct variables

138
Q

What is the syntax for Object destructuring?

A

const { property: [optional], property, property} = object

139
Q

What is the syntax for Array destructuring?

A

const []

140
Q

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

A

left hand declaration assignments instead of right hand

141
Q

What is the syntax for defining an arrow function?

A

variable variable name assignment operator equal sign greater than sign function with return of an expression
no need to define a function with the word function

142
Q

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

A

If you use an expression in the body of an arrow function, you don’t need to use the curly braces.

However, if you use a statement, you must wrap it inside a pair of curly braces as and you have to have a return.

with one parameter parenthesis aren’t required.
no parameters = () parenthesis required

143
Q

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

A

This is defined at the call time of its outer function.

An arrow function doesn’t have its own this value. Instead, it uses the this value of the enclosing lexical scope.

144
Q

What is Node.js?

A

Open source JS tool asynchronous event-driven built for scalable network applications.

145
Q

What can node.js be used for?

A

Be able to handle multiple connections concurrently.

146
Q

what is REPL?

A

Read eval print loop langauage shell. takes single user inputs executes them and returns the result to the user.
accepts an expression from the user and and parses it into a data structure for memory.

147
Q

when was Node.js created?

A

2009 by Ryan Dahl;

148
Q

What is a computer process?

A

process is the active running of code.

can also be the act of manipulating altering or view data

149
Q

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

Over 100 easily

150
Q

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

A

Processes are made up of inputs and outputs so you’d want to know when you’d be able to access those inputs as outputs. Understanding this would allow you to read data, modify data, and then execute a procedure which is pretty much the crux of programming.

151
Q

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

A

global object that can be accessed from anywhere and it provides information about the current Node.js process. It is an instance of the EventEmitter

152
Q

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

A

it is global so you can grab it whenever you want

153
Q

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

A

it is an array of strings. Containing the command line arguments. The first element is the node and the second element is the javascript file argument vector!

154
Q

What is a JavaScript module?

A

It is a way to split up javaScript programming. Good abstraction would be like chapters in a book.
Ultimately, it it is more efficient than having to use a library to do all the extra-client side processing. And allows for better maintainability, reusability of code without worrying about clashing of names.
just a file.

155
Q

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

A

exports, require, module, __filename, and __dirname

156
Q

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

A

the Date Object; Promise object; process object

157
Q

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

A

it allows you to export code to other modules

158
Q

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

A

you use the require function with a parameter of a directory.

159
Q

What is the JavaScript Event Loop?

A

Checks the call stack and the task queue and if the call stack is empty the task queue will come

160
Q

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

A

chunk of code that is running -blocking is put on the call stack and sits there until it is done and then move on.

161
Q

What is a directory?

A

It is a collection. That is holding a collection of files

162
Q

What is a relative file path?

A

it is the files path in relation to where you are in the directory

163
Q

What is an absolute file path?

A

where it is on on the system after the on the root

164
Q

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

A

fs module or file system

165
Q

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

A

writeFile();

166
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous by default

167
Q

What is NPM?

A

Public register of small building blocks that allows you to reuse code. NODE PACKET MANAGER

168
Q

What is a package?

A

A directory with one or more files in it package.json that has meta data about the package

169
Q

How can you create a package.json with npm?

A

You run a CLI questionnaire by navigating to the root directory of your package and then running the npm init command

170
Q

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

A

when you are installing a npm package using npm install package-name that means you are installing it as a dependency

171
Q

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

A

It allows you to use that library or bit of code

172
Q

How do you add express to your package dependencies?

A

npm install express

173
Q

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

A

listen()

174
Q

How do you mount a middleware with an Express application?

A

by calling the use method of the app object

175
Q

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

A

request object and the response object you can also have a callback argument function called next.

176
Q

What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?

A

application/json charset utf 8

177
Q

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

A

It parses the Post request into JSON for you . Whenever you are going to be receiving more complex requests that have JSON bodies.

178
Q

What are the three states a Promise can be in?

A

Pending: which is its initial state/ it hasn’t been fulfilled nor rejected yet. It hasn’t been resolved

fulfilled: meaning it was successful.
rejected: meaning it failed

179
Q

How do you handle the fulfillment of a Promise?

A

then() -one argument function with a promise

180
Q

How do you handle the rejection of a Promise?

A

catch() it has one parameter (the rejection reason)

181
Q

What is Array.prototype.filter useful for?

A

separates indexes that you want out of an array while keeping the original array intact

182
Q

What is Array.prototype.map useful for?

A

When you want to apply an expression over the whole array.

183
Q

What is Array.prototype.reduce useful for?

A

bringing down an array to a single value

184
Q

What is “syntactic sugar”?

A

It means it is easier to read or to write.

185
Q

What is the typeof an ES6 class?

A

function

186
Q

Describe ES6 class syntax.

A

class name of the class in uppercase { constructor()

187
Q

What is “refactoring”?

A

Is the process of refactoring without changing the existing behavior. It is intended to make code simpler and cleaner while increasing performance

188
Q

What is Webpack?

A

its a javascript modular bundler it takes all of your code in your application and makes it usable in a web browser

189
Q

How do you add a devDependency to a package?

A

–save-dev

190
Q

What is an NPM script?

A

it allows you to run multiple commands one right after another instead of manually typing them in the command line

191
Q

How do you execute Webpack with npm run?

A

npm run and script name

192
Q

How are ES Modules different from CommonJS modules?

A

ES6 has declarative syntax like SQL. You describe the file that you want import export. it pre-parses the modules for you

193
Q

What kind of modules can Webpack support?

A

ECMAScript CommonJS and AMD modules

194
Q

What is React?

A

It’s a way to build user interfaces

195
Q

What is a React element?

A

it is an object. A virtual representation of the DOM

196
Q

How do you mount a React element to the DOM?

A

render method of the ReactDOM object

197
Q

What is Babel?

A

it’s a Javascript compiler tool that is mainly used to convert code for backwards compatibility. changes source code and transforms syntax

198
Q

What is a Plug-in?

A

its adds to a specific feature to an existing computer program

199
Q

What is a Webpack loader?

A

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

200
Q

How can you make Babel and Webpack work together?

A

Using a webpack loader

201
Q

What is JSX?

A

Stands for JavaScript XML, which allows us to write HTML in React

202
Q

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

A

Because it needs to be in scope

203
Q

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

A

you use them as dev dependencies babel loader by adding plug-in

204
Q

What is a React component?

A

Similar to a function it allows you to return React elements that will be mounted to the DOM

205
Q

How do you define a function component in React?

A

function call with uppercase(pass in props as a parameter) function code block

206
Q

How do you mount a component to the DOM?

A

render.ReactMethod and pass the function component as an argument

207
Q

What are props in React?

A

Documentation says its an arbitrary input - it is an object

208
Q

How do you pass props to a component?

A

you put it where the parameter would go in a function call

209
Q

How do you write JavaScript expressions in JSX?

A

{ in between }

210
Q

How do you create “class” component in React?

A
using es6 class 
class UPPERCASE extends React.Component {
}
211
Q

How do you access props in a class component?

A

this.props.

212
Q

What is the purpose of state in React?

A

keep track of values of values change over time

condition

213
Q

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

A

onClick props and value is js expression

214
Q

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

A

map

215
Q

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

A

a string that uniquely ids itself

216
Q

What are controlled components?

A

The react component that renders a form also controls what happens in that form..

217
Q

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

A

onChange and value

218
Q

What does fetch() return?

A

promise object

219
Q

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

A

GET

220
Q

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

A

after the url, arg you have an option of adding an init object. You would add a method property with the value of the request method you would like

221
Q

When does React call a component’s componentDidMount method?

A

immediately after a component is inserted into the DOM tree.

222
Q

Name three React.Component lifecycle methods.

A

componentDidMount(), ComponentDidUpdate(),
componentWillUnmount(),
shouldComponentUpdate()

223
Q

How do you pass data to a child component?

A

via props

224
Q

What does express.static() return?

A

returns a string

225
Q

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

A

absolute path

226
Q

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

A

it joins all the path segments together as a string value

227
Q

What must the return value of myFunction be if the following expression is possible?
myFunction()();

A

a function

228
Q
What does this code do?
const wrap = value => () => value;
A

assigning wrap to 2 functions

229
Q

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

A

when it is defined

230
Q

What allows JavaScript functions to “remember” values from their surroundings?

A

closure