C0521 Flashcards

(384 cards)

1
Q

Where do you put non-visible content about the HTML document?

A

Head Element

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

Where do you put visible content about the HTML document?

A

Body Element

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

Where do the head and body tags go in a valid HTML document?

A

HTML Element

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

What is the purpose of a !DOCTYPE declaration?

A

To tell the browser which version of HTML

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

Give five examples of HTML element tags.

A

html, head, body, h1, p

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

What is the purpose of HTML attributes?

A

Attributes provide additional information about the Element

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

Give an example of an HTML entity (escape character).

A

© copyright

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

How do block-level elements affect the document flow?

A

Block-level elements start on a new line

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

How do inline elements affect the document flow?

A

They don’t interrupt the flow

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

What are the default width and height of a block-level element?

A

100% Width, Auto Height

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

What are the default width and height of an inline element?

A

Auto Width, Auto Height

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

What is the difference between an ordered list and an unordered list in HTML?

A

Ordered implies that that the content goes in an order. ie. 1, 2, 3, etc.
Unordered does not have a specific order and by default has bullet points.

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

Is an HTML list a block element or an inline element?

A

Block

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

What HTML tag is used to link to another website?

A

The anchor tag

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

What is an absolute URL?

A

Link to a specific page on the web (external source)

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

What is a relative URL?

A

Link to other pages on the same site (local files)

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

How do you indicate the relative link to a parent directory?

A

../

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

How do you indicate the relative link to a child directory?

A

Name of the directory

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

How do you indicate the relative link to a grand parent directory?

A

../../

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

How do you indicate the relative link to the same directory?

A

Name of the file

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

What is the purpose of an HTML form element?

A

To collect information from visitors

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

Give five examples of form control elements.

A

input, textarea, select, label, button

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

Give three examples of type attributes for HTML input elements.

A

radio, submit, text

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

Is an HTML input element a block element or an inline element?

A

Inline

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the six primary HTML elements for creating tables?
table, thead, tbody, tr, th, td
26
What purpose do the thead and tbody elements serve?
To separate the head and the body of the table
27
Give two examples of data that would lend itself well to being displayed in a table.
Tabular data
28
What are the names of the individual pieces of a CSS rule?
Selector, Declaration, Property, and Value
29
In CSS, how do you select elements by their class attribute?
.
30
In CSS, how do you select elements by their type?
Element name
31
In CSS, how do you select an element by its id attribute?
#
32
Name three different types of values you can use to specify colors in CSS.
Hexcode, RGB, and HSL
33
What CSS properties make up the box model?
Content, Padding, Border, and Margin
34
Which CSS property pushes boxes away from each other?
Margin
35
Which CSS property add space between a box's content and its border?
Padding
36
What is a pseudo-class?
A class added to a selector that specifies a special state of that element
37
What are CSS pseudo-classes useful for?
Adding styling to an element that is in that state
38
Name at least two units of type size in CSS.
px and rem
39
What CSS property controls the font used for the text inside an element?
font-family:
40
What is the default flex-direction of a flex container?
row
41
What is the default flex-wrap of a flex container?
no-wrap
42
Why do two div elements "vertically stack" on one another by default?
divs are a block element
43
What is the default flex-direction of an element with display: flex?
row
44
What is the default value for the position property of HTML elements?
static
45
How does setting position: relative on an element affect document flow?
Doesn't affect document flow
46
How does setting position: relative on an element affect where it appears on the page?
Starts at normal flow position
47
How does setting position: absolute on an element affect document flow?
Doesn't affect flow, gets removed from flow
48
How does setting position: absolute on an element affect where it appears on the page?
The element gets positioned to the nearest positioned ancestor that is non-static
49
How do you constrain an absolutely positioned element to a containing block?
Set parent to a position
50
What are the four box offset properties?
Top, Right, Bottom, Left
51
What is the purpose of variables?
Store information to go back to and use it
52
How do you declare a variable?
var
53
How do you initialize (assign a value to) a variable?
=
54
What characters are allowed in variable names?
Letters, Numbers, Dollar Sign, or an Underscore. Can't start with a number
55
What does it mean to say that variable names are "case sensitive"?
If you capitalize a letter in a variable name, it will be a different variable ie. var score; is different from var Score;
56
What is the purpose of a string?
To contain text or any characters
57
What is the purpose of a number?
To hold numeric value
58
What is the purpose of a boolean?
To provide true or false values
59
What does the = operator mean in JavaScript?
Assign a value to a variable
60
How do you update the value of a variable?
Assign a value to that variable
61
What is the difference between null and undefined?
Null and Undefined are both empty but Null is the developers way of saying empty and Undefined is Javascript's way of saying empty
62
Why is it a good habit to include "labels" when you log values to the browser console?
To know what you are logging and testing
63
Give five examples of JavaScript primitives.
String, Number, Boolean, Undefined, and Null
64
What data type is returned by an arithmetic operation?
Number
65
What is string concatenation?
Adding strings together to make a new string
66
What purpose(s) does the + plus operator serve in JavaScript?
To add numerical values or concatenating strings
67
What data type is returned by comparing two values (, ===, etc)?
Boolean
68
What does the += "plus-equals" operator do?
Shorthand for x = x + y
69
What are objects used for?
To have multiple properties (variables) and methods (functions) under one value
70
What are object properties?
Variables that live within an object
71
Describe object literal notation.
Create an object and give it a name. Inside the pair of curly braces are name-value pairs that are separated by a comma. Those values can be properties (variables) and methods (functions).
72
How do you remove a property from an object?
Use the delete operator and then dot notation for the property in the object ie. delete object.property
73
What are arrays used for?
To store a list of values that are related to each other
74
Describe array literal notation.
Create an array and give it a name. Inside the pair of square brackets are values that are separated by a comma.
75
How are arrays different from "plain" objects?
Arrays have an index
76
What number represents the first index of an array?
0
77
What is the length property of an array?
Returns the number of values in the array
78
How do you calculate the last index of an array?
Subtract 1 from the length
79
What is a function in JavaScript?
A block of code that can be named and used an infinite amount of times
80
Describe the parts of a function definition.
Function Keyword, Function Name, Parameter, Code Block
81
Describe the parts of a function call.
Function Name, and Argument(s)
82
When comparing them side-by-side, what are the differences between a function call and a function definition?
Function keyword, and the code block
83
What is the difference between a parameter and an argument?
Parameters are used when you define a function and arguments are used when you call a function
84
Why are function parameters useful?
Parameters let us run the function with different values instead of having a fixed result.
85
What two effects does a return statement have on the behavior of a function?
Stops the function and takes the result out of the function
86
Why do we log things to the console?
To test our code and see what the value of something is at a certain point
87
What is a method?
A method is a function which is a property of an object
88
How is a method different from any other function?
Methods are properties of an object
89
How do you remove the last element from an array?
The .pop method
90
How do you round a number down to the nearest integer?
Math.floor()
91
How do you generate a random number?
Math.random()
92
How do you delete an element from an array?
The .splice method
93
How do you append an element to an array?
The .push method
94
How do you break a string up into an array?
The .split method
95
Do string methods change the original string? How would you check if you weren't sure?
No, you can check by logging the console of the original string and checking the return value of the documentation
96
Roughly how many string methods are there according to the MDN Web docs?
Over 30
97
Is the return value of a function or method useful in every situation?
Sometimes the return value will be useful but not always ie. splice method return value is the removed value
98
Roughly how many array methods are there according to the MDN Web docs?
Over 30
99
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
100
Give 6 examples of comparison operators.
>, =, <=, ===, !==
101
What data type do comparison expressions evaluate to?
boolean values
102
What is the purpose of an if statement?
the if statement checks if the condition is met to run the code in the block
103
Is else required in order to use an if statement?
no
104
Describe the syntax (structure) of an if statement.
if keyword follow by a condition in between parentheses which is followed by a code block that will run if the condition is met
105
What are the three logical operators?
&&, ||, !
106
How do you compare two different expressions in the same condition?
logical operator
107
What is the purpose of a loop?
To repeat code
108
What is the purpose of a condition expression in a loop?
Permission to run code and also to stop running code
109
What does "iteration" mean in the context of loops?
Each the code block is executed
110
When does the condition expression of a while loop get evaluated?
Beginning of each iteration
111
When does the initialization expression of a for loop get evaluated?
Beginning of everything else and it only happens once
112
When does the condition expression of a for loop get evaluated?
Before each iteration
113
When does the final expression of a for loop get evaluated?
After each iteration
114
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
Break
115
What does the ++ increment operator do?
Adds 1 to the value of a variable
116
How do you iterate through the keys of an object?
For in loop
117
What are the four components of "the Cascade".
Source Order, Inheritance, Specificity, and !important
118
What does the term "source order" mean with respect to CSS?
The last rule that was applied to the same element is stronger than the ones created before it
119
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Inheritance
120
List the three selector types in order of increasing specificity.
Type, Class, ID
121
Why is using !important considered bad practice?
It rules out any other styling and will be harder to debug because it destroys the natural cascade
122
Why do we log things to the console?
To see if the code is working
123
What is a "model"?
A model is a representation of something
124
Which "document" is being referred to in the phrase Document Object Model?
The HTML document
125
What is the word "object" referring to in the phrase Document Object Model?
The objects in the HTML document
126
What is a DOM Tree?
A DOM tree is a model of a web page
127
Give two examples of document methods that retrieve a single element from the DOM.
getElementById() querySelector()
128
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll()
129
Why might you want to assign the return value of a DOM query to a variable?
To quickly access the values of that DOM method so that the code doesn't have to run every time
130
What console method allows you to inspect the properties of a DOM element object?
console.dir()
131
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
To create a model after the whole page has loaded
132
What does document.querySelector() take as its argument and what does it return?
It takes a selector as an argument and returns a JavaScript object or null if nothing is found
133
What does document.querySelectorAll() take as its argument and what does it return?
It takes a selector as an argument and returns a NodeList
134
What is the purpose of events and event handling?
To run code if something occurs
135
What method of element objects lets you set up a function to be called when a specific type of event occurs?
.addEventListener
136
What is a callback function?
A callback function is a function passed into another function as an argument
137
What object is passed into an event listener callback when the event fires?
The event object
138
What is the event.target? If you weren't sure, how would you check? Where could you get more information about it?
The target property of the Event object holds the element that the event was triggered on MDN
139
What is the difference between these two snippets of code? element. addEventListener('click', handleClick) element. addEventListener('click', handleClick())
The first one has a function that will wait til the event happens The second one runs immediately and returns undefined
140
What is the className property of element objects?
The className property is the class name of the element
141
How do you update the CSS class attribute of an element using JavaScript?
Assign the new class name to the className property of the object
142
What is the textContent property of element objects?
The textContent is the text content of the element
143
How do you update the text within an element using JavaScript?
Assign the new text content to the textContent property of the object
144
Is the event parameter of an event listener callback always useful?
No
145
Why is storing information about a program in variables better than only storing it in the DOM?
You can reuse the information stored in variables rather than calling the DOM every time
146
What does the transform property do?
The transform CSS property lets you rotate, scale, skew, or translate an element
147
Give four examples of CSS transform functions.
rotate, scale, skew, translate
148
The transition property is shorthand for which four CSS properties?
transition-property, transition-duration, transition-timing-function, and transition-delay
149
What event is fired when a user places their cursor in a form control?
'focus'
150
What event is fired when a user's cursor leaves a form control?
'blur'
151
What event is fired as a user changes the value of a form control?
'input'
152
What event is fired when a user clicks the "submit" button within a ?
'submit'
153
What does the event.preventDefault() method do?
prevents the default behavior of the event i.e. preventing the data to be in the url
154
What does submitting a form without event.preventDefault() do?
the values in the form will be in the url when the page refreshes
155
What property of a form element object contains all of the form's controls.
.elements
156
What property of form a control object gets and sets its value?
.value
157
What is one risk of writing a lot of code without checking to see if it works so far?
Code could be broken
158
What is an advantage of having your console open when writing a JavaScript program?
Checking for errors
159
Does the document.createElement() method insert a new element into the page?
No
160
How do you add an element as a child to another element?
.appendChild()
161
What do you pass as the arguments to the element.setAttribute() method?
the attribute name and the name of the attribute
162
What steps do you need to take in order to insert a new element into the page?
create the new element, query the parent element from the document, append child to the parent element
163
What is the textContent property of an element object for?
get the text content of an element or replace the value
164
Name two ways to set the class attribute of a DOM element.
.setAttribute() .className
165
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
the function can be reused and will be easier to read code
166
Give two examples of media features that you can query in an @media rule.
min-width and max-width
167
Which HTML meta tag is used in mobile-responsive web pages?
viewport meta tag
168
What is the event.target?
The DOM element object which the event was called on
169
Why is it possible to listen for events on one element that actually happen its descendent elements?
Bubbling
170
What DOM element property tells you what type of element it is?
.tagName
171
What does the element.closest() method take as its argument and what does it return?
its takes a css selector and returns the closest ancestor
172
How can you remove an element from the DOM?
.remove()
173
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?
assign the event listener to the ancestor
174
What is the affect of setting an element to display: none?
The element doesn't show on the page
175
What does the element.matches() method take as an argument and what does it return?
takes a css selector and returns a boolean value
176
How can you retrieve the value of an element's attribute?
.getAttribute()
177
At what steps of the solution would it be helpful to log things to the console?
Every step
178
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?
assign an event listener to each tab
179
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?
write a condition for each view
180
What is a breakpoint in responsive Web design?
The points where the media queries are introduced
181
What is the advantage of using a percentage (e.g. 50%) width instead of a fixed (e.g. px) width for a "column" class in a responsive layout?
Percentages scale to the display where as pixels are different percentages on different displays
182
If you introduce CSS rules for a smaller min-width after the styles for a larger min-width in your style sheet, the CSS rules for the smaller min-width will "win". Why is that?
source order
183
What is JSON?
JSON is a data interchange format used to send and store information in computer systems
184
What are serialization and deserialization?
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.
185
Why are serialization and deserialization useful?
Serialization and deserialization allows the computer to save the state of an object and recreate it when needed
186
How do you serialize a data structure into a JSON string using JavaScript?
.stringify()
187
How do you deserialize a JSON string into a data structure using JavaScript?
.parse()
188
How to you store data in localStorage?
.setItem()
189
How to you retrieve data from localStorage?
.getItem()
190
What data type can localStorage save in the browser?
string (most common is a JSON string)
191
When does the 'beforeunload' event fire on the window object?
right before the window closes
192
What is a method?
A method is a function which is a property of an object
193
How can you tell the difference between a method definition and a method call?
A method definition has code within curly braces with a function keyword and a method call is attached to an object.
194
Describe method definition syntax (structure).
An object with a property that has a value of a function
195
Describe method call syntax (structure).
The method name as a property of an object
196
How is a method different from any other function?
A method is a property of an object.
197
What is the defining characteristic of Object-Oriented Programming?
Objects can contain both data (as properties) and behavior (as methods)
198
What are the four "principles" of Object-Oriented Programming?
Abstraction, Encapsulation, Inheritance, Polymorphism
199
What is "abstraction"?
Abstraction is the process of being able to work with complex things in simple ways
200
What does API stand for?
Application Programming Interface
201
What is the purpose of an API?
an API delivers a user response to a system and sends the system's response back to a user.
202
What is this in JavaScript?
this is an implicit parameter of all JavaScript functions.
203
What does it mean to say that this is an "implicit parameter"?
it's an implicit parameter, meaning that it is available in a function's code block even though it was never included in the function's parameter list or declared with var.
204
When is the value of this determined in a function; call time or definition time?
call time
205
``` 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); } }; ```
"this" is referring to the object character.
206
Given the above character object, what is the result of the following code snippet? Why? character.greet();
It's-a-me, Mario!
207
``` Given the above character object, what is the result of the following code snippet? Why? var hello = character.greet; hello(); ```
It's-a-me, undefined!
208
How can you tell what the value of this will be for a particular function or method definition?
"this" will be the object that the method is defined in.
209
How can you tell what the value of this is for a particular function or method call?
"this" will be the object that the method is attached to.
210
What kind of inheritance does the JavaScript programming language use?
prototype-based inheritance
211
What is a prototype in JavaScript?
An object with a set of data that other objects can use.
212
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?
The methods are properties of the prototype object of those data types.
213
If an object does not have its own property or method by a given key, where does JavaScript look for it?
The prototype object
214
What does the new operator do?
The new operator 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.
215
What property of JavaScript functions can store shared behavior for instances created with new?
The prototype property
216
What does the instanceof operator do?
The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object.
217
What is a "callback" function?
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
218
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?
setTimeout()
219
How can you set up a function to be called repeatedly without using a loop?
setInterval()
220
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
0ms which will execute immediately
221
What do setTimeout() and setInterval() return?
timeoutID and intervalID which are positive non-zero integers that can be passed through clearTimeout() and clearInterval() to cancel the timeout/interval.
222
What is a client?
A client requests content or services from a server
223
What is a server?
A server host runs one or more server programs, which share their resources with clients
224
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
225
What three things are on the start-line of an HTTP request message?
A HTTP method, the request target (usually a URL), the HTTP version
226
What three things are on the start-line of an HTTP response message?
The protocol version, status code, status text
227
What are HTTP headers?
HTTP headers let the client and the server pass additional information with an HTTP request or response.
228
Where would you go if you wanted to learn more about a specific HTTP Header?
MDN
229
Is a body required for a valid HTTP request or response message?
Not all
230
What is AJAX?
AJAX is a technique for loading data into part of a page without having to refresh the entire page
231
What does the AJAX acronym stand for?
AJAX stands for Asynchronous JavaScript and XML
232
Which object is built into the browser for making HTTP requests in JavaScript?
XMLHttpRequest
233
What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?
load
234
An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?
The XMLHttpRequest object shares the same prototype from eventTarget.
235
What is a code block? What are some examples of a code block?
A code block is code within curly braces. | For example, code for an if statement and loops.
236
What does block scope mean?
Variables defined inside the code block mean they only exist in that code block.
237
What is the scope of a variable declared with const or let?
block-scoped
238
What is the difference between let and const?
const creates a read only reference to the value
239
Why is it possible to .push() a new value into a const variable that points to an Array?
pushing a new value to an array doesn't change the name of the variable declared by const.
240
How should you decide on which type of declaration to use?
You want to use const always unless you can not.
241
What is the syntax for writing a template literal?
`` aka backticks and to include variables and expressions, you would use ${}
242
What is "string interpolation"?
the ability to substitute part of the string for the values of variables or expressions.
243
What is destructuring, conceptually?
Declaring multiple variables at once from properties of an object or elements of an array.
244
What is the syntax for Object destructuring?
const { propertyName: newVariableName } = object; or const { newVariableName } = object; (if the property name is the same)
245
What is the syntax for Array destructuring?
const [newVariableName] = array;
246
How can you tell the difference between destructuring and creating Object/Array literals?
the {} and [] on the left side of the assignment operator means destructuring and if they are on the right side, and object or array is being created.
247
What is the syntax for defining an arrow function?
One parameter. With a simple expression return is not needed: param => expression Multiple parameters require parentheses. With simple expression return is not needed: (param1, paramN) => expression ``` Multiline statements require body brackets and return: param => { let a =1; return a + param; } ``` ``` Multiple parameters require parentheses. Multiline statements require body brackets and return: (param 1, paramN) => { let a = 1; return a + param1 + paramN; } ```
248
When an arrow function's body is left without curly braces, what changes in its functionality?
The expression is returned.
249
How is the value of this determined within an arrow function?
An arrow function captures the this value of the enclosing context instead of creating its own this context.
250
What is a CLI?
Command-line Interface
251
What is a GUI?
Graphical User Interface
252
``` Give at least one use case for each of the commands listed in this exercise. man cat ls pwd echo touch mkdir mv rm cp ```
man: shows the manual of a specific command cat: displays the text content of a file into the terminal ls: shows the contents of the directory you are in pwd: prints the name of the current/working directory echo: displays a line of text touch: create a new file mkdir: makes directories mv: renames files rm: removes files or directories cp: makes a copy of files and directories
253
What are the three virtues of a great programmer?
Laziness, Impatience, Hubris
254
What is Node.js?
Node.js is a JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.
255
What can Node.js be used for?
Node.js is primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It's used for traditional web sites and back-end API services, but was designed with real-time, push-based architectures in mind.
256
What is a REPL?
Read-eval-print loop
257
When was Node.js created?
2009
258
What back end languages have you heard of?
JavaScript, Python, PHP, Ruby, C++, C#, C, Java, Go (Golang)
259
What is a computer process?
A computer process is the instance of a computer program that is being executed by one or many threads.
260
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
Hundreds
261
Why should a full stack Web developer know that computer processes exist?
The code that a web developer writes are computer processes.
262
What is the process object in a Node.js program?
The process object is a global that provides information about, and control over, the current Node.js process.
263
How do you access the process object in a Node.js program?
Just like any other object
264
What is the data type of process.argv in Node.js?
String
265
What is a JavaScript module?
an individual .js file
266
What values are passed into a Node.js module's local scope?
exports, require, module, __filename, and __dirname
267
Give two examples of truly global variables in a Node.js program.
process and global
268
What is the purpose of module.exports in a Node.js module?
To export a function and store it in the exports property of the module object so that other modules can import those functions.
269
How do you import functionality into a Node.js module from another Node.js module?
Use the require method with the module that you want to import as the argument.
270
What is the JavaScript Event Loop?
The process where code is put in a call stack in order to execute code.
271
What is different between "blocking" and "non-blocking" with respect to how code is executed?
Blocking code is code that is occupying the call stack while it is executing and non-blocking code gets removed from the call stack when it is executed.
272
What is a directory?
a file that lists other files
273
What is a relative file path?
a point to a file in the same directory
274
What is an absolute file path?
a point to a file starting from the root of the directory
275
What module does Node.js include for manipulating the file system?
the fs module
276
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile()
277
Are file operations using the fs module synchronous or asynchronous?
both
278
What is a client?
Clients request content or services from a server
279
What is a server?
Servers respond to clients with the information that they requested if possible
280
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
281
What is on the first line of an HTTP request message?
an HTTP method like a verb (GET, PUT, or POST) or a noun like (HEAD or OPTIONS) , the request target (usually a URL), the HTTP version
282
What is on the first line of an HTTP response message?
The protocol version, a status code, and a status text
283
What are HTTP headers?
HTTP headers let the client and the server pass additional information with an HTTP request or response.
284
Is a body required for a valid HTTP message?
No
285
What is NPM?
NPM is the world's largest software registry that developers use to share and borrow packages. NPM can be the website, the Command Line Interface (CLI), or the registry.
286
What is a package?
A package is a directory described by a package.json file
287
How can you create a package.json with npm?
npm init --yes
288
What is a dependency and how do you add one to a package?
A dependency is a package that lets the dependent package run. You can add one to a package using npm install.
289
What happens when you add a dependency to a package with npm?
The package gets placed into the dependencies key of the package.
290
How do you add express to your package dependencies?
npm install express
291
What Express application method starts the server and binds it to a network PORT?
the listen method
292
How do you mount a middleware with an Express application?
the use method
293
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req for request and res for response
294
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
295
What does the express.json() middleware do and when would you need it?
Parses JSON and would use it if you need to parse the request body.
296
What is the significance of an HTTP request's method?
To know what to do with the data given whether it be GET, POST, DELETE, etc.
297
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS). Other relational databases are MySQL, SQL Server by Microsoft, and Oracle by Oracle Corporation.
298
What are some advantages of learning a relational database?
You use the SQL language and they are the most widely used kind of database
299
What is one way to see if PostgreSQL is running?
sudo service postgresql status
300
What is a database schema?
A collection of tables which defines how the data in a relational database should be organized.
301
What is a table?
A table is a list of rows each having the same set of attributes.
302
What is a row?
A row is a data record within a table.
303
What is SQL and how is it different from languages like JavaScript?
SQL is a declarative programming language. In declarative languages, programmers describe the results they want and the programming environment comes up with its own plan for getting those results.
304
How do you retrieve specific columns from a database table?
select
305
How do you filter rows based on some specific criteria?
where
306
What are the benefits of formatting your SQL?
readability
307
What are four comparison operators that can be used in a where clause?
= < > !=
308
How do you limit the number of rows returned in a result set?
limit
309
How do you retrieve all columns from a database table?
*
310
How do you control the sort order of a result set?
order by
311
How do you add a row to a SQL table?
insert into
312
What is a tuple?
a tuple is a list of values
313
How do you add multiple rows to a SQL table at once?
after each tuple, add a comma and then add another tuple
314
How do you get back the row being inserted into a table without a separate select statement?
returning
315
How do you update rows in a database table?
update and set
316
Why is it important to include a where clause in your update statements?
to know which rows to update instead of everything in the table
317
How do you delete rows from a database table?
delete from and specifying where
318
How do you accidentally delete all rows from a table?
delete from without specifying where
319
What is a foreign key?
A value that refers to another column in another table
320
How do you join two SQL tables?
join "table name" using ("foreign key")
321
How do you temporarily rename columns or tables in a SQL statement?
as
322
What are some examples of aggregate functions?
count("columnName") sum("columnName")
323
What is the purpose of a group by clause?
To separate rows into groups and to perform aggregate functions on those groups
324
What are the three states a Promise can be in?
pending: initial state, neither fulfilled nor rejected. fulfilled: meaning that the operation was completed successfully. rejected: meaning that the operation failed.
325
How do you handle the fulfillment of a Promise?
Use the then method of the returned promise object and pass in the callback function to run if the promise is fulfilled
326
How do you handle the rejection of a Promise?
Use the catch method of the return promise object and pass in the callback function to run if the promise is unfulfilled
327
What is Array.prototype.filter useful for?
It lets you filter an array with a condition which will check if each index meets the condition. The method will return a new array of values that met the condition.
328
What is Array.prototype.map useful for?
It lets you modify the array with an expression which will return a new array with new values at each index
329
What is Array.prototype.reduce useful for?
It lets you call a function to every index and returns the accumulation of all the return values of the function
330
What is "syntactic sugar"?
syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express.
331
What is the typeof an ES6 class?
function
332
Describe ES6 class syntax.
class keyword followed by the class name and a pair of curly braces. Within the curly braces, you can assign properties to the class by using the constructor function. Also you can assign methods to the class by defining the function without the function keyword.
333
What is "refactoring"?
code refactoring is the process of restructuring existing computer code while maintaining functionality
334
What is Webpack?
Webpack is a module that can bundle dependencies together so that the application doesn't have to run on script tags which will bottleneck the browser and performance
335
How do you add a devDependency to a package?
npm install --save-dev
336
What is an NPM script?
npm scripts are shortcuts to execute in a cli
337
How do you execute Webpack with npm run?
npm run build
338
How are ES Modules different from CommonJS modules?
ES modules have more compact syntax compared the CommonJS, the structure can be statically analyzed, and the support for cyclic dependencies are better than CommonJS.
339
What kind of modules can Webpack support?
ECMAScript, CommonJS, AMD Modules, Assets, WebAssembly Modules
340
What is React?
React is a JavaScript library for building user interfaces
341
What is a React element?
Object
342
How do you mount a React element to the DOM?
ReactDOM.render(element, container)
343
What is Babel?
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.
344
What is a Plug-in?
a Plug-in is a software component that adds a specific feature to an existing computer program.
345
What is a Webpack loader?
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.
346
How can you make Babel and Webpack work together?
install the babel-loader as a devDependency
347
What is JSX?
JSX is a syntax extension to JavaScript based in ES6. JSX allows you to write HTML in React by converting HTML into React components
348
Why must the React object be imported when authoring JSX in a module?
the syntax for JSX gets converted to react which will show react when it converts it
349
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
install @babel/plugin-transform-react-jsx and babel-loader as a devDependency
350
What is a React component?
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
351
How do you define a function component in React?
function FunctionName(props) { return someJSX; }
352
How do you mount a component to the DOM?
ReactDOM.render(element, container);
353
What are props in React?
Props are properties for react elements.
354
How do you pass props to a component?
take the prop as a parameter and then you can access it by the property of the props
355
How do you write JavaScript expressions in JSX?
{ JavaScript Expression }
356
How do you create "class" component in React?
class nameOfClass extends React.Component. The class must have a render function inside of it.
357
How do you access props in a class component?
this.props
358
What is the purpose of state in React?
The purpose of a state in React is to know which React element to render based on the state.
359
How to you pass an event handler to a React element?
you would pass it by setting the onClick prop to the event handler function but you would need to bind that function so that the 'this' will be known in the future.
360
What are controlled components?
An input form element whose value is controlled by React. When the user's inputs are set into the form's state and the React element is rendered based on the value of the state.
361
What two props must you pass to an input for it to be "controlled"?
value and onChange
362
What Array method is commonly used to create a list of React elements?
the map method
363
What is the best value to use as a "key" prop when rendering lists?
The best way to pick a key is to use a string that uniquely identifies a list item among its siblings.
364
What does express.static() return?
middleware function
365
What is the local __dirname variable in a Node.js module?
the directory name of the current module
366
What does the join() method of Node's path module do?
The path.join() method joins all given path segments together
367
What does fetch() return?
a promise
368
What is the default request method used by fetch()?
GET
369
How do you specify the request method (GET, POST, etc.) when calling fetch?
The second argument for the fetch function takes in an object. In that object, you can set the value for the 'method' property to a different request method.
370
When does React call a component's componentDidMount method?
After a component is mounted
371
Name three React.Component lifecycle methods
constructor(), render(), componentDidMount(), componentDidUpdate(), componentWillUnmount()
372
How do you pass data to a child component?
store the data as the value of a property in the state property of the component
373
What must the return value of myFunction be if the following expression is possible? myFunction()();
myFunction must return a function
374
``` What does this code do? const wrap = value => () => value; ```
returns the second arrow function which takes no parameters and returns the value of the variable value
375
in JavaScript, when is a function's scope determined; when it is called or when it is defined?
defined
376
What allows JavaScript functions to "remember" values from their surroundings?
lexical scoping
377
What does the acronym LIFO mean?
Last In First Out
378
What methods are available on a Stack data structure?
stack. peek() stack. pop() stack. print()
379
What must you do to access the value at an arbitrary point in a stack (not just the "top")?
pop all values until you get to the point
380
What does the acronym FIFO mean?
First In First Out
381
What methods are available on a Queue data structure?
queue. peek() queue. dequeue() queue. enqueue()
382
What must you do to access the value at an arbitrary point in a queue (not just the "front")?
dequeue the value and check if that is the value you want. if not, enqueue the value.
383
How are linked lists different from an array?
linked lists have a next. arrays have an index.
384
How would you access an arbitrary node in a linked list (not just the "head")?
.next until you get to the point