JavaScript Flashcards

1
Q

What is the purpose of variables?

A

To store data for use

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

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

A

variable name = (assignment operator) variable value;

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

What characters are allowed in variable names?

A

letters, dollar sign, underscore, numbers (cannot start with a number)

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

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

A

variable with that same name but different casing is a different variable

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

What is the purpose of a string?

A

store and use text data

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

What is the purpose of a number?

A

store and use numeric data

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

What is the purpose of a boolean?

A

boolean is a data type with two values true/false can be used to for decision making

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

What does the = operator mean in JavaScript?

A

assignment operator, assigns value to a variable

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

How do you update the value of a variable?

A

variable name = (assignment operator) new value

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

What is the difference between null and undefined?

A
o	undefined:
	computationally empty
	value and type are undefined
o	null:
	 means nothing
	value is null type is object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

to see what is being logged and in what order

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

Give five examples of JavaScript primitives.

A
o	string
o	number
o	boolean
o	undefined
o	null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
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
14
Q

What is string concatenation?

A

Join two or more strings together

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

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

A

o Addition

o Concatenation

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

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

A

adds the value of the variable to the right operand and assigns the result to the variable i.e.:
x += y means: x = x + y

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

What are objects used for?

A
grouping related data 
variables (properties) and 
functionality functions(methods) together
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are object properties?

A

key: value pairs

data attached to a name, data may change, name will stay the same
a variable attached to a object

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

Describe object literal notation.

A
const/let objName = { } 
can include properties  and methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do you remove a property from an object?

A

delete (keyword) object.(member operator)property

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

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

A

o Dot notation object.(member operator)property/method = (assignment operator) value

o Bracket notation object[“property”] = (assignment operator) value

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

What are arrays used for?

A

storing a list of values

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

Describe array literal notation.

A

var keyword arrayName = (assignment operator) [value, value, value];

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

How are arrays different from “plain” objects?

A

arrays are ordered and use numbered indices instead of property names

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

What is the length property of an array?

A

holds the number of items in the array

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

How do you calculate the last index of an array?

A

arrayName.length -1

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

What is a function in JavaScript?

A

a block of code that performs a task

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

Describe the parts of a function definition.

A

o Function keyword
o Function name (optional)
o Opening and closing parenthesis which may include a comma separated list of parameters
o A code block surrounded by curly braces
o Return statement (optional)

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

Describe the parts of a function call.

A

o Function name

o Opening and closing parenthesis which may include a comma separated list of arguments

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

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

A

Function call does not have the function keyword or the code block surrounded by curly braces and the parameters are now arguments

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

What is the difference between a parameter and an argument?

A

o A parameter is declared when defining a function to hold the place for a value
o Arguments are the values that are passed to the function when it is called

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

Why are function parameters useful?

A

o Provide data to the function

o Can provide different data for different results without having to repeat code

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

o Causes the function to produce a value for use

o Exits the function and prevents any more of the function’s code block from being run

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

For debugging and to check output

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

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

How is a method different from any other function?

A

Attached to object so able to access the information on that object so has greater functionality.

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

.pop(); method

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

Math.floor(number);

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

Math.random();

0 to .9repeating

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

.splice(index, number); method

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(); 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(pattern ie ‘ ‘); 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?

A

No, strings are immutable the only way to save a string with changes is to create a new variable to hold new string

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

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

A

Not if you don’t need to see or use the return value at the moment.

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

Give 6 examples of comparison operators.

A
o	=== strictly equal to (value and type)
o	!== not strictly equal to (value and type)
o	> greater than
o	> less than
o	>= greater than or equal to 
o	<= less than or equal to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
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
49
Q

What is the purpose of an if statement?

A

To make a decision. Evaluates a condition and if true executes the code block.

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

Describe the syntax (structure) of an if statement.

A

o if keyword
o condition surrounded by parentheses
o code block surrounded by curly braces

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

What are the three logical operators?

A

o && logical and
o || logical or
o ! logical not

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

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

A

(expression1 > comparison operator expression2)

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

What is the purpose of a loop?

A

To run a block of code multiple times.

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

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

A

Defines the condition required to run the code block, once false loop ends

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

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

A

Loop repetition

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

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

A

Before each loop iteration

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

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

A

One time before the first time the condition is evaluated.

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

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

A

Before each loop iteration.

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

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

A

At the end of each loop iteration before the next evaluation of condition

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

What does the ++ increment operator do?

A

Adds one to its operand and returns a value

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

Why do we log things to the console?

A

To check output and for debugging

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

What is a “model”?

A

A representation/recreation of something

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

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

A

The HTML document

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

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

A

The JavaScript objects that are modelling the HTML document

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

What is a DOM Tree?

A

A model of an element and all of it’s children

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

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

A
o	getElementById() uses the value of an element’s id attribute
o	querySelector() uses a CSS selector, and returns the first matching element
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

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

A
o	querySelectorAll() uses a CSS selector to select all matching elements
o	getElementsByClassName() selects all elements that have a specific value for their class attribute
o	getElementsByTagName() selects all elements that have the specified tag name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q

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

A

To store the reference for it for future use, don’t have to search the whole DOM tree again.

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

What console method allows you to inspect the properties of a DOM element object?

A

.dir()

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

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

A

The browser needs to analyze all of the elements in the HTML page first.

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

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

A

A string holding a CSS selector, the first matching element

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

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

A

A string holding a CSS selector, a node list of all matching elements

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

What is the purpose of events and event handling?

A

o To respond to the actions of our users.
o Events are what happens
o Event listeners to trigger functions when an event occurs

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

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

A

optional

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

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

A

The event object which contains all the information about that event.

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

What is the event.target?

A

The target property of the event object the value of which is the element that the event originated from

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

What is the difference between these two snippets of code?

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

A
  1. the function is passed as an argument (callback function)

2. the function is called and will be replaced by the return of the function call

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

What is the className property of element objects?

A

get and set the value of a class attribute

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

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

A

element.className = ‘newValue’

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

What is the textContent property of element objects?

A

get and set the value of text content of an element and it’s descendants

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

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

A

element.textContent = ‘new value’

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

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

A

No, don’t always need the info stored in event.

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

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

A

Easy to see and use values multiple times, faster than searching the DOM tree every time

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

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

A

input

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

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

A

submit

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

What does the event.preventDefault() method do?

A

prevents the default behavior of the event

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

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

A

refreshes the page and adds the form’s values to the URL

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

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

A

value

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

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

A

difficult to debug

98
Q

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

A

verify code as you go

99
Q

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

A

no

100
Q

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

A

o element.appendChild(childelement);

o element.append(childelement);

101
Q

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

A

(attribute name, value)

102
Q

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

A

o Create element node
o Get element to append the new element to.
o Add element to DOM tree (append to parent element)

103
Q

What is the textContent property of an element object for?

A

Get(read) or set(write) text content of an element and it’s children

104
Q

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

A

o element.setAttribute(name, value);

o element.className = ‘attribute’;

105
Q

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

A

o Define once, repeat as many times needed
o Dynamic
o Name the purpose of the code block

106
Q

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

A

event bubbling & event capturing

107
Q

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

A

tagName

108
Q

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

A
o	selectors (a string containing a selector or selector list)
o	returns itself or the first matching ancestor, null if no matches
109
Q

How can you remove an element from the DOM?

A

ChildNode.remove() method

110
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

add event listener to an ancestor element

111
Q

What is the event.target?

A

the most specific element the event happened on

112
Q

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

A

Turns off the display of an element and it’s children so it has no effect on the layout, the document is rendered as though they doesn’t exist, taken out of document flow

113
Q

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

A

o A string representing the selector to test

o A boolean

114
Q

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

A

element.getAttribute(‘attribute name’) method

115
Q

What is JSON?

A

JavaScript Object Notation

116
Q

What are serialization and deserialization?

A

Serialization is the processes of translating an object into a format that can be stored or transmitted (JSON is string) and deserialization is the reverse of that process, reconstructing the object

117
Q

Why are serialization and deserialization useful?

A
o	To transmit an object across a network
o	Persistence (storage)
118
Q

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

A

JSON.stringify();

119
Q

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

A

JSON.parse();

120
Q

How to you store data in localStorage?

A

localStorage.setItem(keyName, keyValue);

121
Q

How to you retrieve data from localStorage?

A

localStorage.getItem(KeyName);

122
Q

What data type can localStorage save in the browser?

A

string

123
Q

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

A

When the window, document and its resources are about to be unloaded (refresh, close, etc)

124
Q

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

A

a function definition being assigned to an object.

object.method();

125
Q

Describe method definition syntax (structure).

A
const/let objectName = {
	propertyName: function(parameters) {
		code block};
	}[comma here if multiple methods]
};
126
Q

Describe method call syntax (structure).

A

objectName.methodName();

127
Q

How is a method different from any other function?

A

Attached to an object so it access and sometimes modify that object’s data.

128
Q

What is the defining characteristic of Object-Oriented Programming?

A

Objects pair both data (as properties) and behavior (as methods)

129
Q

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

A

o Abstraction
o Encapsulation
o Inheritance
o Polymorphism

130
Q

What is “abstraction”?

A

The ability to interact with something complex in a simple way

131
Q

What does API stand for?

A

Application Programming Interface

132
Q

What is the purpose of an API?

A

To be able to interact with a system in a simplified way (abstraction)

133
Q

What is this in JavaScript?

A

the object to the left of the dot

134
Q

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

A

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

135
Q

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

A

call

136
Q

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

A

You can’t

137
Q

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

A

The value to the left of the dot when the method is called, if there is none, will default to window object.

138
Q

What kind of inheritance does the JavaScript programming language use?

A

Prototype-based/prototypal inheritance

139
Q

What is a prototype in JavaScript?

A

An object that contains properties and methods that can be used as a template for other objects to use.

140
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 are defined on a prototype object that they utilize.

141
Q

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

A

Prototype objects

142
Q

What does the new operator do?

A

o Creates a blank object.
o Adds a property to the new object __proto__ that links to the constructor function’s prototype object.
o Binds the newly created object instance as the this context
o Returns this if the function doesn’t return an object

143
Q

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

A

Prototype

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

145
Q

What is a “callback” function?

A

A function passed to another function as an argument

146
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()

147
Q

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

A

setInterval()

148
Q

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

A

0ms

149
Q

What do setTimeout() and setInterval() return?

A

timeoutID / intervalID a positive number that identifies the timer created by the call

150
Q

What is a client?

A

programs that request data from a server

151
Q

What is a server?

A

computer program that stores and transmits data to other computers on the network when asked to

152
Q

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

A

GET

153
Q

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

A

o HTTP method
o Request target
o HTTP version

154
Q

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

A

o The protocol version
o A status code
o A status text

155
Q

What are HTTP headers?

A

The meta data for the request/response

156
Q

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

A

no

157
Q

What is AJAX?

A

A technique for requesting and loading data onto a part of the page without having to refresh the entire page using XMLHTTPRequest

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

Prototype chain (EventTarget)

162
Q

What are some examples of a code block?

A

Loops

Conditionals

163
Q

What does block scope mean?

A

Variables can only be accessed within the code block curly braces

164
Q

What is the difference between let and const?

A

Const variable is immutate; it cannot be reassigned

Const must be assigned value on declaration

165
Q

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

A

Because an array is an object so it is pass by reference and is mutable

166
Q

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

A

Use const unless you can’t, then use let

167
Q

What is the syntax for writing a template literal?

A

Surrounded by backticks

expressions ${}

168
Q

What is “string interpolation”?

A

Substituting expression values in a string

169
Q

What is destructuring, conceptually?

A

Assigning property values of an object to variables

170
Q

What is the syntax for Object destructuring?

A

Const/let {

propertyKey: variableName,

171
Q

What is the syntax for Array destructuring?

A

Const/let [variableName, variableName] = arrayName;

172
Q

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

A

{} or [] on left or right of the assignment operation

173
Q

What is the syntax for defining an arrow function?

A

() => expression; expression; expression {multiple expressions or statements}

174
Q

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

A

Don’t need a return statement

175
Q

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

A

Determined at definition time by the value of this in the enclosing code block, window if none

176
Q

What is a CLI?

A

Command Line Interface

177
Q

What is a GUI?

A

Graphical User Interface

178
Q
o	man
o	cat
o	ls
o	pwd
o	echo
o	touch
o	mkdir
o	mv
o	rm
o	cp
A
o	man
	look at the manual for a program
o	cat
	concatenate files, create new files, see contents of a file > create new file
o	ls
	list directory contents
o	pwd
	print name of working directory
o	echo
	print a line of text > create new file
o	touch
	create a file without content (ie: .gitkeep)
o	mkdir
	make directories (parent directories with -p option)
o	mv
	rename or move files
o	rm
	remove files (directories with -r option)
o	cp
	copy files (directories with -r option)
179
Q

What is Node.js?

A

a runtime environment that allows JavaScript to be executed outside of a web browser

180
Q

What can Node.js be used for?

A

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

181
Q

What is a REPL?

A

read-eval-print loop: an interactive shell that reads user inputs, executes them, and returns the result

182
Q

What is a computer process?

A

The instance of a program that is being executed

183
Q

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

A

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

184
Q

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

A

globally available by referring to the name

185
Q

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

A

An array of strings

186
Q

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

A

To program applications where client, server and database work together

187
Q

What is a JavaScript module?

A

a .js file

188
Q

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

A
o	exports
o	require
o	module
o	\_\_filename
o	\_\_dirname
189
Q

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

A

o process
o global
o console

190
Q

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

A

To make data and functions available to other modules

191
Q

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

A

require() method

192
Q

What is a directory?

A

a file container

193
Q

What is a relative file path?

A

The location of a file or directory relative to the current directory

194
Q

What is an absolute file path?

A

The complete location of a file or directory starting from root

195
Q

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

A

fs

196
Q

What is the JavaScript Event Loop?

A

It moves asynchronous functions in the task queue to the call stack when it is empty

197
Q

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

A

Blocking code stays on the stack until complete, non-blocking code pushed to the task queue

198
Q

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

A

writeFile() method

199
Q

Are file operations using the fs module synchronous or asynchronous?

A

They have asynchronous and synchronous methods

200
Q

What is NPM?

A

npm website, command line client, package registry

201
Q

What is a package?

A

a directory with one or more files and has a package.json

202
Q

How can you create a package.json with npm?

A

npm init -y

203
Q

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

A

files required by a package, npm install

204
Q

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

A

package.json gets updated to include the new dependency and the dependency files get downloaded

205
Q

How do you add express to your package dependencies?

A

npm install express

206
Q

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

A

listen method

207
Q

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

A

application/json

208
Q

What are the three states a Promise can be in?

A

o pending: initial state, neither fulfilled nor rejected.
o fulfilled: meaning that the operation was completed successfully.
o rejected: meaning that the operation failed.

209
Q

How do you handle the fulfillment of a Promise?

A

then method

210
Q

How do you handle the rejection of a Promise?

A

catch method

211
Q

What is Array.prototype.filter useful for?

A

Filtering an array to show only the values that meet your criteria

212
Q

What is Array.prototype.map useful for?

A

Creating a new array with the return of a function being called on each element of an array

213
Q

What is Array.prototype.reduce useful for?

A

Combining the elements in an array into a single value

214
Q

What is “syntactic sugar”?

A

syntax within a programming language that is designed to make things easier for humans to read or to write

215
Q

What is “syntactic sugar”?

A

syntax within a programming language that is designed to make things easier for humans to read or to write

216
Q

What is the typeof an ES6 class?

A

function

217
Q

Describe ES6 class syntax.

A
class Name {
    constructor(property(ies)) {
        this.property = property;
    }
    method() {
        return this.property;
    }
}
218
Q

What is “refactoring”?

A

restructuring existing code without changing its external behavior (usually to improve readability, reduce complexity, or improve performance)

219
Q

What is Webpack?

A

A module bundler for JavaScript applications

220
Q

How do you add a devDependency to a package?

A

npm install –save-dev

221
Q

How do you execute Webpack with npm run?

A

npm run key

222
Q

How are ES Modules different from CommonJS modules?

A

Use import or {} from ‘./filepath’ and export instead of const variable = require(‘file’) & module.exports = ;

223
Q

What kind of modules can Webpack support?

A
o	ECMA Script modules
o	CommonJS modules
o	AMD modules
o	Assets
o	WebAssembly modules
224
Q

What is React?

A

a JavaScript library/framework for creating user interfaces

225
Q

What is a React element?

A

An object modeling a DOM node

226
Q

How do you mount a React element to the DOM?

A

ReactDOM.render(element, container)

227
Q

What is Babel?

A

A JavaScript compiler* mainly used to translate JavaScript to an older version of JavaScript (*program that translates from one language to another)

228
Q

What is a Plug-in?

A

A software component that adds a feature to an existing program

229
Q

What is a Webpack loader?

A

A plug in that can transform a source module’s code as it is imported

230
Q

How can you make Babel and Webpack work together?

A

install babel-loader as a devDependency

231
Q

What is JSX?

A

A syntax extension for JavaScript that produces React elements

232
Q

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

A

Because when you make elements it compiles to React.createElement()

233
Q

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

A

Install plug-in: npm install @babel/plugin-transform-react-jsx

234
Q

What is a React component?

A

A function that takes an input and returns a React element

235
Q

How do you define a function component in React?

A

function Name(props) { return <h1>Hello, {props.user} </h1>;}

236
Q

How do you mount a component to the DOM?

A

ReactDOM.render(element, container)

237
Q

What are props in React?

A

Properties used for passing data from one component to another

238
Q

How do you pass props to a component?

A

Use a key=”value” pair when creating element

239
Q

How do you write JavaScript expressions in JSX?

A

{expression}

240
Q

How do you create “class” component in React?

A
class Welcome extends React.Component {
 	render() {
  		return <h1>Hello, {this.props.name}</h1>;
 	}
}
241
Q

How do you access props in a class component?

A

Property of the this object