JavaScript Flashcards

1
Q

What is the purpose of variables?

A

Purpose of variables is to store data/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

Declaring a variable you need the variable keyword: var and giving it a name: variable 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

You assign a value by using the assignment operator: ‘=‘

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

Characters allowed in the variable names are letters, dollar sign, and underscore

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

When variables are “case sensitive” the same named variable is different when one of the words are capitalized.

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

Purpose of a string is to add new content into a page.

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

Purpose of a number is calculating, determining the size of the screen, moving the position of an element, or setting the amount of time an element should take to fade in.

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

Purpose of a boolean is to determine 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

“=“ means the value is being assigned to a variable

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 use the same variable and assign it to 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

undefined is a variable that hasn’t been defined to anything and null is a variable that is intentionally missing a value.

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

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

A

Labels can help us with what we’re referring to specific variables/values.

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

Give five examples of JavaScript primitives.

A

5 primitives: null, undefined, string, boolean, 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

Number

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

What is string concatenation?

A

When you’re joining multiple strings into 1 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

Adding values and concatenation strings

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

It adds the value to a variable and then assigns the result to the variable

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

What are objects used for?

A

Objects are used to store/group data

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

What are object properties?

A

Object properties are variables associated with the object

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

Describe object literal notation.

A

Object Literal Notation consists of the variable object with properties and methods, and in the properties consists of keys and values, methods consists of functions.

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

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

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

A

dot or bracket notations

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

What is a function in JavaScript?

A

Its a set a statements that perform a task

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

Describe the parts of a function definition.

A

function keyword, name of the function, parameter, and curly braces

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

Describe the parts of a function call.

A

function name and parenthesis

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

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

A

definition uses parameters and has a function code block
call uses arguments to pass in

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

What is the difference between a parameter and an argument?

A

Parameters stores variables that can be used later and is used in a function definition
argument is used in a function call

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

Why are function parameters useful?

A

You pass in different arguments in the parameters

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

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

A

It stops the code from running
it will returns any value in the code block

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

Why do we log things to the console?

A

It tells us what the code is doing

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

What is a method?

A

Method is a property of an object that has a function definition

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

How is a method different from any other function?

A

Methods are assigned with an object property, while a function is not

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

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

A

floor() method

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

How do you generate a random number?

A

random() method

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

How do you delete an element from an array?

A

shift() method, pop() method, or splice() method

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

How do you append an element to an array?

A

push() method, or unshift() method

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

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

A

Does not change.
console.log() to check

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

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

A

Roughly 50 string methods

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

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

A

Roughly 40 array methods

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

Give 6 examples of comparison operators.

A

6 comparison operator: equal (=), not equal (!=), strictly equal (===), strictly not equal (!===), greater than (>), greater than or equal (>=), less than (<), less than or equal (<=).

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

What is the purpose of an if statement?

A

It is to run the code if the condition is met

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

Describe the syntax (structure) of an if statement.

A

if (condition) {
statement
} else {
statement
}

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

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

A

Compare two expressions with the logical operator

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

What is the purpose of a loop?

A

Its to repeat a task a set number of times.

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

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

A

To cause a loop to end.

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

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

A

It is when the condition passes in the loop.

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

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

A

Before executing the statement

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

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

A

The beginning of the loop

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

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

A

At the end of each loop interation

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

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

A

When the condition expression evaluates to false

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

What does the ++ increment operator do?

A

It adds one to variable in the initial conditional expression

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

Why do we log things to the console?

A

It tells us what the code is doing

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

What is a “model”?

A

The model is the DOM tree made up of objects. Any representation of the DOM.

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

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

A

The document is the webpage; it can be displayed in the browser or the HTML source.

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

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

A

“object” refers to the object of the document.

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

What is a DOM Tree?

A

DOM Tree is a model of a web page.

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

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

A

To get individual nodes, you use getElementById() or querySelector.

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

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

A

To get multiple elements at once, you use getElementByClassName() - returns an HTML collection, getElementsByTagName(), or querySelectorAll() - returns a static NodeList.

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

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

A

Because you might work with an element more than once.

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

Why would a

 tag need to be placed at the bottom of the HTML content instead of at the top?
A
<script>
is placed at the end so it gives time for the HTML load before any javascript code runs. This will speed up the website response time.
</script>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

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

A

querySelector() uses a CSS selector as the argument and returns the first matching element.

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

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

A

querySelectorAll() uses a CSS selector as the argument and returns all matching elements.

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

Why do we log things to the console?

A

To see what the code is doing

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

What is the purpose of events and event handling?

A

Purpose of events is to make the page feel interactive for the user.
Purpose of event handling is to run a code when the event takes place that allows web pages to respond.

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

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

A

No, you don’t have to use parameters

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

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

A

addEventListener() method lets you set up a function to be called when a specific type of event occurs.

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

What is a callback function?

A

callback function is a function passed into another function as an argument.

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

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

A

event object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
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 is represents with the element that is interacted with.
check MDN

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

What is the className property of element objects?

A

Value of the class attribute

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

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

A

className property

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

What is the textContent property of element objects?

A

Text content of the node

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

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

A

textContent property

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

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

A

It will be more accurate because the DOM can be manipulated therefore the information may be changed.

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

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

A

focus event

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

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

A

blur event

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

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

A

input event

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

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

A

submit event

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

What does the event.preventDefault() method do?

A

Prevents the browser to automatically reload the page

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

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

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

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

A

elements property

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

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

A

value property

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

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

A

You won’t know what part of the code in correct, unless you use the debugger that can be time consuming

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

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

A

You know when you make a mistake in your code

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

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

A

no

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

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

A

appendChild() method

100
Q

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

A

name of the attribute and value of that attribute

101
Q

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

A

you have to append the new element to the element on the page

102
Q

What is the textContent property of an element object for?

A

its the text content for the element

103
Q

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

A

className
setAttribute()

104
Q

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

A

call a function anytime we want.
can pass in objects into functions

105
Q

What is the event.target?

A

event.target: it targets a specified element. It gives us access to the properties of the specified element. The element that dispatches the event.

106
Q

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

A

event delegation

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

closest() takes a selector as the argument and returns the closest ancestor that matches the selector.

109
Q

How can you remove an element from the DOM?

A

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

You will add an event listener to the parent element and you can add code to the function code block

111
Q

What is the event.target?

A

event.target: it targets a specified element. It gives us access to the properties of the specified element. The element that dispatches the event.
Element that is interacted with.

112
Q

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

A

The element disappears. Removes it from the document.

113
Q

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

A

Element.matches() takes a string that contains a CSS Selector and returns a boolean.

114
Q

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

A

getAttribute() method

115
Q

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

A

every step

116
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

Add another event listener for the tab.

117
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

if statement

118
Q

What is JSON?

A

JSON is a text-based format that stores data.

119
Q

What are serialization and deserialization?

A

Serialization turns an object and stores it into a file, database, or memory
Deserialization does the process in reverse.

120
Q

Why are serialization and deserialization useful?

A

To receive and store data

121
Q

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

A

JSON.stringify() method

122
Q

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

A

JSON.parse() method

123
Q

How do you store data in localStorage?

A

You store data with the setItem() method

124
Q

How do you retrieve data from localStorage?

A

You retrieve data with the getItem() method

125
Q

What data type can localStorage save in the browser?

A

Strings

126
Q

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

A

When you refresh the browser

127
Q

What is a method?

A

Method is a property of an object that has a function definition.

128
Q

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

A
129
Q

Describe method definition syntax (structure).

A

object.name of method ()

130
Q

Describe method call syntax (structure).

A

object.name of method

131
Q

How is a method different from any other function?

A

it is very similar, but you would use the object to call of method

132
Q

What is the defining characteristic of Object-Oriented Programming?

A

properties have values that can contain functions

133
Q

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

A

abstraction, encapsulation, inheritance, polymorphism

134
Q

What is “abstraction”?

A

taking simple functionality to do complex things

135
Q

What does API stand for?

A

application programming interface

136
Q

What is the purpose of an API?

A

API allows programmers to access parts of the data without knowing how the program works

137
Q

What is this in JavaScript?

A

refers to the object

138
Q

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

A

this can be called even though its not in the code block

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?
var character = {
firstName: ‘Mario’,
greet: function () {
var message = ‘It's-a-me, ‘ + this.firstName + ‘!’;
console.log(message);
}
};

A

this refers to character

141
Q

Given the above character object, what is the result of the following code snippet? Why?
character.greet();

A

Its a me, mario

142
Q

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

A

its a me undefined because this refers to the window object that does not have a first name property

143
Q

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

A

we do not know what this is for a function or method definition

144
Q

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

A

we will know by the left side of the dot which is the object

145
Q

What kind of inheritance does the JavaScript programming language use?

A

Javascript language uses prototype-based inheritance

146
Q

What is a prototype in JavaScript?

A

prototype is an object that contains properties and methods that can be used by other objects.

147
Q

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

A

Their methods are defined on a prototype object and they borrow the methods
prototypical inheritance

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 checks the prototype chain

149
Q

What does the new operator do?

A

creates an object from a constructor function

150
Q

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

A

prototype property

151
Q

What does the instanceof operator do?

A

Checks if the object is the instance of the constructor

152
Q

What is a “callback” function?

A

a function passed into another function as an argument

153
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() function

154
Q

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

A

setInterval() function

155
Q

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

A

setInterval() function

156
Q

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

A

0 is the default value

157
Q

What do setTimeout() and setInterval() return?

A

non-zero

158
Q

What is a client?

A

A Client is a computer hardware or software that requests information or applications from a server

159
Q

What is a server?

A

An application that stores, sends, and receives data

160
Q

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

A

GET method

161
Q

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

A

HTTP method / Request target / HTTP Version

162
Q

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

A

Protocol version / status code / status text
302 -> redirected to another page
500 -> server error
404 -> not good
200 -> good!

163
Q

What are HTTP headers?

A

HTTP Header is additional context and data about the request or response.
Between servers and clients

164
Q

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

A

MDN

165
Q

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

A

No

166
Q

What is AJAX?

A

Conceptual Idea to asynchronously get data without having to refresh the webpage

167
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript and XML

168
Q

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

A

XMLHTTPRequest();

169
Q

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

A

‘load’ Event

170
Q

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

A

They share the same prototype.
Prototypical Inheritance

171
Q

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

A

Code that is inside the curly braces; loops or if else statement

172
Q

What does block scope mean?

A

code thats within the curly braces

173
Q

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

A

block scope

174
Q

What is the difference between let and const?

A

const is immutable and can’t be reassigned once it’s been declared; let is mutable => update the values

175
Q

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

A

Its possible because you can update the value, but can’t assign the array to another array

176
Q

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

A

Everything should be const until you can’t use it, then use let.
let can also be used in for loops

177
Q

What is the syntax for writing a template literal?

A

backticks and for substitutions you will use the Syntax -> ${variable_name};

178
Q

What is “string interpolation”?

A

It allows us to replace variables and expressions with their values in a string.

179
Q

What is destructuring, conceptually?

A

its a different way to assign properties to variables

180
Q

What is the syntax for Object destructuring?

A

const/let variable keyword, curly braces; property: variable

181
Q

What is the syntax for Array destructuring?

A

const keyword, square brackets and variable names within the brackets that are corresponding the array index followed by assignment operator and array that is being deconstructed.

182
Q

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

A

You can tell by the structure of the syntax

183
Q

CLI?

A

command-line interface

184
Q

GUI?

A

graphical user interface

185
Q

cat?

A

concatenate files

186
Q

ls

A

get a list of the contents of a file

187
Q

pwd?

A

current working directory

188
Q

echo?

A

displays a line of text

189
Q

touch?

A

modify the times of files

190
Q

mkdir?

A

create new directories

191
Q

mv?

A

move or rename files

192
Q

history?

A

prints the command line history

193
Q

cp?

A

copy files and directories

193
Q

rm?

A

deletes files

195
Q

What are the three virtues of a great programmer?

A

laziness, impatience, and hubris

196
Q

What is the syntax for defining an arrow function?

A

const/let keyword = (parameter) => {expression}

197
Q

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

A

it returns the expression without using the return keyword; implicit return

198
Q

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

A

first lexical scope of the first object thats outside in the global space

199
Q

What is Node.js?

A

a program that allows JavaScript to be run outside of a web browser

200
Q

What can Node.js be used for?

A

Scripting language

201
Q

What is a REPL?

A

Have a language to run in the background
read-eval-print loop

202
Q

When was Node.js created?

A

2009

203
Q

What back end languages have you heard of?

A

Java, python, ruby

204
Q

What is a computer process?

A

the instance of a computer program that is being executed by one or many threads.

205
Q

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

A

Around mid 60s

206
Q

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

A

To make applications. Need to build things to work with and interact with the processes

207
Q

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

A

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

208
Q

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

A

typing out process or require method with a string process as the argument. => require(‘process’);

209
Q

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

A

array

210
Q

What is a JavaScript module?

A

a .js file

211
Q

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

A

module, __filename, __dirname

212
Q

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

A

process

213
Q

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

A

It gives access to other files. Share information

214
Q

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

A

Use the require(path) function with the location/path of the file

215
Q

What is the JavaScript Event Loop?

A

In charge of what code goes to the call stack

216
Q

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

A

Blocking executes the code synchronously
Non-blocking executes the code asynchronously

217
Q

What is a directory?

A

A folder that contains multiple types of files

218
Q

What is a relative file path?

A

A direction of the file to the source within the same directory

219
Q

What is an absolute file path?

A

The root to the

220
Q

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

A

‘fs’ module

221
Q

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

A

fs.writeFile() method

222
Q

Are file operations using the fs module synchronous or asynchronous?

A

Asynchronous but certain methods can allow it to be synchronous

223
Q

What is NPM?

A

its a software registry
massive collection of modules.

224
Q

What is a package?

A

Directory that contains files. Also contains package.json with meta data about the package.
its a module we can get access to

225
Q

How can you create a package.json with npm?

A

npm init –yes

226
Q

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

A

It’s a package that your project package needs in order to work
npm install (npm i) command followed by the name of the package
2 types:
dev dependencies
normal dependencies

227
Q

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

A

It creates a node_modules directory

228
Q

How do you add express to your package dependencies?

A

npm install express

229
Q

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

A

listen method();

230
Q

How do you mount a middleware with an Express application?

A

use() method of the app object

231
Q

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

A

request object and response object

232
Q

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

A

application/json

233
Q

What is the significance of an HTTP request’s method?

A

It allows the client and server to communicate

234
Q

What is PostgreSQL and what are some alternative relational databases?

A

Its an open source database.
MySQL, SQL Server by Microsoft, Oracle by Oracle Corporation.

235
Q

What are some advantages of learning a relational database?

A

SQL is the common language.

236
Q

What is one way to see if PostgreSQL is running?

A

you can check the status of the postgreSQL service to see if its running
command —> sudo service postgresql status

237
Q

What is a database schema?

A

It’s a structure of data. Collection of tables

238
Q

What is a table?

A

Collections of columns and rows.
Each column is a

239
Q

What is a row?

A
240
Q

What is SQL and how is it different from languages like JavaScript?

A
241
Q

How do you retrieve specific columns from a database table?

A

Select statement with the column names in double quotes

242
Q

How do you filter rows based on some specific criteria?

A

where clause

243
Q

What are the benefits of formatting your SQL?

A

Easy to read

244
Q

What are four comparison operators that can be used in a where clause?

A

<, >, =, !=

245
Q

How do you limit the number of rows returned in a result set?

A

limit clause with a positive integer

246
Q

How do you retrieve all columns from a database table?

A
  • asterisk
247
Q

How do you control the sort order of a result set?

A

order by clause then name of the column