Quiz Questions Flashcards

1
Q

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

A

. It’s about the meta information
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

The body tag of the HTML document

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

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

A

The tag will usually go right after the tag and before the tag. The tag will go after the tag.

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

What is the purpose of a declaration?

A

The purpose is to tell a browser which version of HTML the page is using

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

Give five examples of HTML element types.

A

, <li>, <ul>, ,
</ul></li>

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

Provides additional information about the contents of an 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

< less than <
> greater than >

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

Makes certain elements start on a new line in the browser window

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

Makes it appear to continue on the same line as their neighboring elements

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

Expands to a width of 100% of its parent container and the height would be according to the height of the content

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

The height and width of the content

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: numbered
Unordered: bullet point

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 element

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

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

Linking to a different website / a full web address for the site

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

What is a relative URL?

A

When linking to other pages within the same site

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

use ../ to indicate the folder above the current one, then follow it with the file name
example: <a>Home</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

use the name of the child folder, followed by a forward slash, then the file name
example: <a></a>

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 the same directory?

A

just use the file name (nothing else is needed)
example: <a>Reviews</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 a sibling directory?

A

use ../ to indicate the folder above the current one, then with a forward slash, write the sibling folder, then write the file name
example: <a>Home</a>

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

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

A

repeat the ../ to indicate that you want to go up two folders (rather than one), then follow it with the file name
example: <a>Home</a>

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

What is the purpose of an HTML form element?

A

collect data from users

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

Give five examples of form control elements.

A

text input
password input
radio buttons
checkboxes
dropdown boxes

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

Give three examples of type attribute values for HTML elements.

A

type=”image” when you want to use an image for the submit button
type=”submit” used to send a form to the server
type=”file” creates a box that looks like a text input followed by a browse button to select a file from their cmp and upload it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Is an HTML element a block element or an inline element?
inline block
26
What are the six primary HTML elements for creating tables?
table row tr table data td table heading th table header thead table body tbody table footer tfoot
27
What purpose do the thead and tbody elements serve?
thead - headings of the table tbody - body/data of the table
28
Give two examples of data that would lend itself well to being displayed in a table.
stock reports train timetables sports results
29
What are the names of the individual pieces of a CSS rule?
selector, declaration, property, value
30
In CSS, how do you select elements by their class attribute?
period and class name .class { }
31
In CSS, how do you select elements by their type?
match the element names example: h1, h2, h3 {}
32
In CSS, how do you select an element by its id attribute?
33
Name three different types of values you can use to specify colors in CSS.
rgb, hex codes, color names
34
What CSS properties make up the box model?
border margin padding
35
Which CSS property pushes boxes away from each other?
margin
36
Which CSS property add space between a box's content and its border?
padding
37
What is a pseudo-class?
keyword added to a selector that specifies a special state of the selected elements
38
What are CSS pseudo-classes useful for?
lets you apply a style to an element, not only in relation to the actual content, but to external factors like position of mouse, history of the navigator, etc
39
Name two types of units that can be used to adjust font-size in CSS.
pixels percentages ems
40
What CSS property controls the font used for the text inside an element?
font-family
41
What is the default flex-direction of a flex container?
row
42
What is the default flex-wrap of a flex container?
nowrap: all flex items will be on one line
43
Why do two div elements "vertically stack" on one another by default?
because they're block elements
44
What is the default flex-direction of an element with display: flex?
row
45
What is the default value for the position property of HTML elements?
static
46
How does setting position: relative on an element affect document flow?
doesn't affect the position of surround elements and they will stay in the position they would be in normal flow
47
How does setting position: relative on an element affect where it appears on the page?
you could change the position of the element where it would otherwise have been in normal flow it doesn't inherently affect where it appears, but you can move it from the original position
48
How does setting position: absolute on an element affect document flow?
it affects the document flow, as the other elements would simply ignore the space it would have taken up
49
How does setting position: absolute on an element affect where it appears on the page?
does not necessarily affect where it appears on the page, but it can affect where it appears on the page
50
How do you constrain an absolutely positioned element to a containing block?
using a relative position
51
What are the four box offset properties?
top bottom left right
52
What are the four components of "the Cascade".
source order inheritance specificity !important
53
What does the term "source order" mean with respect to CSS?
the order that your css rules are written in your spreadsheet styling provided last in your spreadsheet is the one that will take effect
54
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
inheritance
55
List the three selector types in order of increasing specificity.
ID - CLASS - VALUE
56
Why is using !important considered bad practice?
it has side effects that mess with specificity VERY HARD TO OVERRIDE reverses the cascade order of stylesheets
57
What is the purpose of variables?
a temporary storage for data types
58
How do you declare a variable?
specify the type, leave at least one space, then the name for the variable and end the line with a semicolon;
59
How do you initialize (assign a value to) a variable?
use an assignment operator after the variable keyword and name, then give it its value
60
What characters are allowed in variable names?
letter, $, underscore, numbers
61
What does it mean to say that variable names are "case sensitive"?
there is a difference in identification of the variables using uppercase and using lowercase letters
62
What is the purpose of a string?
data type that is used to represent text
63
What is the purpose of a number?
data type that represents numbers
64
What is the purpose of a boolean?
data type that is used to create true/false statements
65
What does the = operator mean in JavaScript?
assignment operator to perform operations on the variables and values (operands)
66
How do you update the value of a variable?
reassign the value of the variable you don't have to write the keyword var again
67
What is the difference between null and undefined?
undefined: primitive variable that has been declared but not defined yet / it is undefined null: assigned nothing value / it is an object
68
Why is it a good habit to include "labels" when you log values to the browser console?
helps you debug as well and gives context of what to expect in the console
69
Give five examples of JavaScript primitives.
string number boolean undefined null
70
What data type is returned by an arithmetic operation?
number
71
What is string concatenation?
the combination of 2+ strings to form one string
72
What purpose(s) does the + plus operator serve in JavaScript?
concatenation (strings) and addition (numbers)
73
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
74
What does the += "plus-equals" operator do?
addition assignment operator adds the value of the right operand to a variable and assigns the result to the variable
75
What are objects used for?
to group together a set of variables/functions to create of model of something you'd recognize from the real world
76
What are object properties?
variables set to the object
77
Describe object literal notation.
first define a variable and assign it a properties inside a curly brace keys:value then end it with a curly brace
78
How do you remove a property from an object?
delete key.value
79
What are the two ways to get or update the value of a property?
dot notation method hotel.name = 'Park'; square bracket method hotel['name'] = 'Park';
80
What are arrays used for?
stores a list of values
81
Describe array literal notation.
var colors; colors = ['white', 'black', 'custom'];
82
How are arrays different from "plain" objects?
in an object, the order of the properties is not important however, in an array, the index numbers dictate the order of the properties
83
What number represents the first index of an array?
0
84
What is the length property of an array?
holds the number of items in the array
85
How do you calculate the last index of an array?
subtracting 1 from the length of an array gives the last index of an array
86
What is a function in JavaScript?
a set of statements that performs a task or calculates a value
87
Describe the parts of a function definition.
function keyword to start optional name comma separated list of 0+ parameters start of a function's code block optional return statement end of the function's code block shown by }
88
Describe the parts of a function call.
function's name comma separated list of 0+ arguments surrounded by ()
89
When comparing them side-by-side, what are the differences between a function call and a function definition?
if there is a code block, it's a function definition, if not it's a function call
90
What is the difference between a parameter and an argument?
parameter is a placeholder argument is actual value
91
Why are function parameters useful?
92
What two effects does a return statement have on the behavior of a function?
makes functions more reusable and flexible
93
Why do we log things to the console?
to debug our code validate our assumptions about how something works
94
What is a method?
function which is a property of an object
95
How is a method different from any other function?
a method is associated with an object, while a function is not
96
How do you remove the last element from an array?
pop() method
97
How do you round a number down to the nearest integer?
Math.floor() method
98
How do you generate a random number?
Math.random() method
99
How do you delete an element from an array?
splice() method pop() method shift() method
100
How do you append an element to an array?
push() method unshift () method splice() method
101
How do you break a string up into an array?
string.split() method
102
Do string methods change the original string? How would you check if you weren't sure?
it does not mutate the original string you can assign a variable to the original string and check it at the end
103
Roughly how many string methods are there according to the MDN Web docs?
60-70 methods
104
Is the return value of a function or method useful in every situation?
no, it's only useful when you need the function/method to return something ex: pop(), shift() method
105
Roughly how many array methods are there according to the MDN Web docs?
around 40 methods (?)
106
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
107
Give 6 examples of comparison operators.
== equal to === strict equal to =! not equal to ==! strict not equal to > greater than < less th an
108
What data type do comparison expressions evaluate to?
boolean
109
What is the purpose of an if statement?
to check if a condition is true or false
110
Is else required in order to use an if statement?
a code block to execute if the value is true
111
Describe the syntax (structure) of an if statement.
112
What are the three logical operators?
logical && logical || logical !
113
How do you compare two different expressions in the same condition?
logical && logical ||
114
What is the purpose of a loop?
to repeat a portion of code a set number of times until the desired process is complete
115
What is the purpose of a condition expression in a loop?
tells how many times the loop should continue running until the counter reaches a certain number
116
What does "iteration" mean in the context of loops?
each time the code runs
117
When does the condition expression of a while loop get evaluated?
before executing the statement again once before the initialization
118
When does the initialization expression of a for loop get evaluated?
occurs one time only before the loop begins
119
When does the condition expression of a for loop get evaluated?
each time before the loop runs
120
When does the final expression of a for loop get evaluated?
at the end of each loop iteration
121
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break statement
122
What does the ++ increment operator do?
increment the value of a variable by 1 and reassigning it
123
How do you iterate through the keys of an object?
Using the for in statement.
124
Why do we log things to the console?
it's a feature for debugging purposes
125
What is a "model"?
general def: representation
126
Which "document" is being referred to in the phrase Document Object Model?
the document node in the DOM tree (webpage)
127
What is the word "object" referring to in the phrase Document Object Model?
the nodes in the dom tree
128
What is a DOM Tree?
model of the webpage
129
Give two examples of document methods that retrieve a single element from the DOM.
getElementById() querySelector()
130
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementsByClassName('class') getElementsByTagName('tagName')
131
Why might you want to assign the return value of a DOM query to a variable?
to store the location of the element in a variable saves the browser looking through the DOM tree to find the same element again caches the selection
132
What console method allows you to inspect the properties of a DOM element object?
console.dir()
133
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
if you place the script tag on top, it'll load up the main.js and run the dom, making the webpage take longer to load and slow down the pg rendering speed
134
What does document.querySelector() take as its argument and what does it return?
takes a string containing one or more selector and returns the element object representing the first element in the doc that matches the argument returns null if it doesn't find anything
135
What does document.querySelectorAll() take as its argument and what does it return?
argument: selectors returns: all of those elements that match the selector in a node list
136
Why do we log things to the console?
to debug to see what our code is doing
137
What is the purpose of events and event handling?
`we want to get events to trigger some sort of JS code allows our page to be more interactive
138
Are all possible parameters required to use a JavaScript method or function?
no
139
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener()
140
What is a callback function?
function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action
141
What object is passed into an event listener callback when the event fires?
the event object
142
What is the event.target? If you weren't sure, how would you check? Where could you get more information about it?
target property of the event object point of interaction on the dom the object that dispatches the event
143
What is the difference between these two snippets of code? element.addEventListener('click', handleClick) element.addEventListener('click', handleClick())
144
What is the className property of element objects?
`
145
How do you update the CSS class attribute of an element using JavaScript?
146
What is the textContent property of element objects?
147
How do you update the text within an element using JavaScript?
148
Is the event parameter of an event listener callback always useful?
No
149
Would this assignment be simpler or more complicated if we didn't use a variable to keep track of the number of clicks?
more complicated
150
Why is storing information about a program in variables better than only storing it in the DOM?
151
What does the transform property do?
CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.
152
The transition property is shorthand for which four CSS properties?
transition delay, transition timing function
153
What event is fired when a user places their cursor in a form control?
focus()
154
What event is fired when a user's cursor leaves a form control?
blur()
155
What event is fired as a user changes the value of a form control?
change
156
What event is fired when a user clicks the "submit" button within a form?
submit
157
What does the event.preventDefault() method do?
prevents the default behavior
158
What does submitting a form without event.preventDefault() do?
it will reload the page
159
What property of a form element object contains all of the form's controls.
elements property
160
What property of a form control object gets and sets its value?
value attribute use object.value
161
What is one risk of writing a lot of code without checking to see if it works so far?
you won't know which parts don't work
162
What is an advantage of having your console open when writing a JavaScript program?
163
Does the document.createElement() method insert a new element into the page?
no, it is not yet part of the dom tree until it is appended
164
How do you add an element as a child to another element?
you can use append child
165
What do you pass as the arguments to the element.setAttribute() method?
the element you would want to be appended or made a child\ element, value
166
What steps do you need to take in order to insert a new element into the page?
1. createElement() 2. optionally, you setAttribute() and createTextNode() 3. appendChild() to add it to the page
167
What is the textContent property of an element object for?
The text content of the element and all descendaces, with spacing and CSS hidden text, but without tags
168
Name two ways to set the class attribute of a DOM element.
setAttribute() className property
169
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
we're able to call the function more than once
170
What is the event.target?
gets the element on which the event originally occurred
171
Why is it possible to listen for events on one element that actually happen its descendent elements?
due to event capturing?
172
What DOM element property tells you what type of element it is?
tagName
173
What does the element.closest() method take as its argument and what does it return?
it takes the css selector you want to match the element and its ancestors against returns the first ancestor of the selected element
174
How can you remove an element from the DOM?
remove()
175
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?
adding an event listener to the parent element
176
What is the event.target?
event that is being targeted element interacted with the element that dispatches the event
177
What is the effect of setting an element to display: none?
the affected element will disappear and will not take up space in the web page
178
What does the element.matches() method take as an argument and what does it return?
argument: takes in a css selector returns: true if the element matches the selectors, otherwise false
179
How can you retrieve the value of an element's attribute?
getAttribute()
180
At what steps of the solution would it be helpful to log things to the console?
181
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?
add addeventlistener for each element
182
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?
display none and display show? with buttons?
183
Give two examples of media features that you can query in an @media rule.
184
Which HTML meta tag is used in mobile-responsive web pages?
meta name="viewport"
185
What is a breakpoint in responsive Web design?
the point at which a website's content and design will adapt in a certain way in order to provide the best possible user experience
186
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?
you don't know the pixel count for every screen so it makes everything relative to the screen columns are boxes so they can negotiate between those breakpoints and maintain their shape and boxes
187
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?
because the css rules for the smaller min-width was written after rules at the end of the style sheet take precedence over the front rules
188
What is JSON?
extremely common data interchange format used to send and store information in computer systems
189
What are serialization and deserialization?
process of converting an Object into stream of bytes so that it can be transferred over a network or stored in a persistent storage reverse process: turning a stream of bytes into an object in memory
190
Why are serialization and deserialization useful?
Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization
191
How do you serialize a data structure into a JSON string using JavaScript?
using the JSON.stringify() method
192
How do you deserialize a JSON string into a data structure using JavaScript?
usign the JSON.parse() method
193
How do you store data in localStorage?
setItem()
194
How do you retrieve data from localStorage?
getItem()
195
What data type can localStorage save in the browser?
string data
196
When does the 'beforeunload' event fire on the window object?
197
What is a method?
a function which is a property of an object
198
How can you tell the difference between a method definition and a method call?
199
Describe method definition syntax (structure).
keyword function with function name and with (parameter) open curly brace for the code block with whatever you want it to execute then close curly brace
200
Describe method call syntax (structure).
function object of a property with an argument in the parenthesis`
201
How is a method different from any other function?
method is associated with an object, while a function is not
202
What is the defining characteristic of Object-Oriented Programming?
objects can contain both data (as properties) and behavior (as methods)
203
What are the four "principles" of Object-Oriented Programming?
abstraction encapsulation inheritance polymorphism
204
What is "abstraction"?
being able to work with complex things in simple ways
205
What does API stand for?
application programming interface
206
What is the purpose of an API?
give programmers a way to interact with a system in a simplified, consistent fashion
207
What is this in JavaScript?
an implicit parameter of all JavaScript functions
208
What does it mean to say that this is an "implicit parameter"?
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
209
When is the value of this determined in a function; call time or definition time?
call time
210
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); } };
object character
211
Given the above character object, what is the result of the following code snippet? Why? character.greet();
It's a me Mario! we are calling the greet method of the character object.
212
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 because var hello does not have a value stored for the firstName property
213
How can you tell what the value of this will be for a particular function or method definition?
we would not know from the definition!
214
How can you tell what the value of this is for a particular function or method call?
"the object to the left of the dot" when the function is called (as a method).
215
What kind of inheritance does the JavaScript programming language use?
prototype-based inheritance
216
What is a prototype in JavaScript?
original model on which something is patterned
217
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?
because they are prototyped onto it
218
If an object does not have it's own property or method by a given key, where does JavaScript look for it?
_proto_
219
What does the new operator do?
lets developers create an instance of user-defined object type or of one of the built-in object types that has a constructor function
220
What property of JavaScript functions can store shared behavior for instances created with new?
prototype property
221
What does the instanceof operator do?
test to see if the prototype property of a constructor appears anywhere in the prototype chain of an object
222
What is a "callback" function?
function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action
223
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() function
224
How can you set up a function to be called repeatedly without using a loop?
setInterval()
225
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
0 or immediately
226
What do setTimeout() and setInterval() return?
The returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout(). This value can be passed to clearTimeout() to cancel the timeout. The returned intervalID is a numeric, non-zero value which identifies the timer created by the call to setInterval(); this value can be passed to clearInterval() to cancel the interval.
227
What is a client?
service requesters program that's capable
228
What is a server?
providers of a resource or service provides whatever the request is
229
Which HTTP method does a browser issue to a web server when you visit a URL?
GET request
230
What three things are on the start-line of an HTTP request message?
HTTP method - describing what action to be performed request target - usually a URL or the absolute path of the protocol, port, and domain are usually characterized by the request context HTTP version - defines the structure of the remaining message, acting as an indicator of the expected version to use for the `response
231
What three things are on the start-line of an HTTP response message?
1. The protocol version, usually HTTP/1.1. 2. A status code, indicating success or failure of the request. Common status codes are 200, 404, or 302 3. A status text. A brief, purely informational, textual description of the status code to help a human understand the HTTP message.
232
What are HTTP headers?
let the client and server pass additional information with an HTTP request or response consists of its case-insensitive name followed by a colon, then by its value meta information allows us to get or put information about the request
233
Is a body required for a valid HTTP request or response message?
NO, responses with a status code that sufficiently answer the request without the need for corresponding payload usually don't
234
Where would you go if you wanted to learn more about a specific HTTP Header?
MDN
235
What is AJAX?
technique for loading data into part of a pg without having to refr3esh the entire pg
236
What does the AJAX acronym stand for?
asynchronous javascript and xml
237
Which object is built into the browser for making HTTP requests in JavaScript?
XMLHttpRequest object
238
What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?
'load'`
239
Bonus Question: An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?
prototypical inheritance
240
What is a code block? What are some examples of a code block?
statements to be executed
241
What does block scope mean?
restricts the variable that is declared inside a specific block, from access by the outside of the block
242
What is the scope of a variable declared with const or let?
block scope
243
What is the difference between let and const?
let can be reassigned while const cannot
244
Why is it possible to .push() a new value into a const variable that points to an Array?
we are adding new elements to the array, but we are not reassigning the array
245
How should you decide on which type of declaration to use?
if you know that the value won't/can't be reassigned, use const if you know that the value will/can be reassigned, use let, esp for loops or mathematical algorithms where the value is changing
246
What is the syntax for writing a template literal?
uses backticks and use a backslash if the string contains a backtick \n for new liens interpolation: ${ }
247
What is "string interpolation"?
the ability to transform a string so that it is safe to include in HTML
248
What is destructuring, conceptually?
to dismantle something to unpack values from arrays or properties from objects into distinct variables
249
What is the syntax for Object destructuring?
const or let { property1: variable1, property2: variable2 } = object;
250
What is the syntax for Array destructuring?
let [x, y, z] = array;
251
How can you tell the difference between destructuring and creating Object/Array literals?
the assignment is after the curly braces for creating, for destructuring, writing the actual value is not required
252
What is the syntax for defining an arrow function?
=>
253
When an arrow function's body is left without curly braces, what changes in its functionality?
it implicitly returns
254
How is the value of this determined within an arrow function?
arrow function captures the this value of the enclosing context instead of creating its own this context uses it from the enclosing lexical scope
255
What is a CLI?
command-line interfaces
256
What is a GUI?
graphical user interface aimed for users of the technology, not the producers
257
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 - interface to the system reference manuals cat - to concatenate files to standard output ls - list directory contents pwd - print name of current/working directory (print working directory) echo - display a line of text touch - change file timestamps mkdir - make directories mv - move (rename) files rm - remove files or directories cp - copy files and directories
258
What are the three virtues of a great programmer?
laziness, hubris, impatience
259
What is Node.js?
program that allows JavaScript to be run outside of a web browser environment that allows us to execute Javascript code without a browser
260
What can Node.js be used for?
used to build back ends for web applications, command-line programs, or any kind of automation that developers wish to perform
261
What is a REPL?
read-eval-print loop takes single user inputs, executes them, and returns the result to the user
262
When was Node.js created?
may 27 2009
263
What back end languages have you heard of?
Ruby, Python, Java
264
What is the process object in a Node.js program?
global that provides information about, and control over, the current Node.js process object that has a lot of info about node js
265
How do you access the process object in a Node.js program?
using require() globally available
266
What is the data type of process.argv in Node.js?
array
267
What is a JavaScript module?
single .js file
268
What values are passed into a Node.js module's local scope?
filename dirname
269
Give two examples of truly global variables in a Node.js program.
dirname filename console process object
270
What is the purpose of module.exports in a Node.js module?
instructions that allow us to export from a given file so that other files are allowed to access the exported code
271
How do you import functionality into a Node.js module from another Node.js module?
require()
272
What is the JavaScript Event Loop?
constantly running process that monitors both the callback queue and the call stack
273
What is different between "blocking" and "non-blocking" with respect to how code is executed?
blocking is executed synchronously non-blocking is executed asynchronously
274
What is a directory?
file system cataloging structure
275
What is a relative file path?
the path related to the present working directly(pwd)
276
What is a absolute file path?
always contains the root element and the complete directory list required to locate the file
277
What module does Node.js include for manipulating the file system?
file system module fs module
278
What method is available in the Node.js fs module for writing data to a file?
writefile method
279
Are file operations using the fs module synchronous or asynchronous?`
asynchronous
280
What is NPM?
world's largest software registry
281
What is a package?
directory with one or more files in it
282
How can you create a package.json with npm?
use the npm init command
283
What is a dependency and how to you add one to a package?
another package that your package needs in order to work npm install
284
What happens when you add a dependency to a package with npm?
Install the dependencies to the local node_modules folder.
285
How do you add express to your package dependencies?
npm install express
286
What Express application method starts the server and binds it to a network PORT?
listen method
287
How do you mount a middleware with an Express application?
use method
288
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req - request object res - response object next - function that triggers the request to be sent to the next middleware - lets us break our logic into multiple pieces
289
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
290
What is the significance of an HTTP request's method?
So we can indicate what the intent of the request method is
291
What does the express.json() middleware do and when would you need it?
parses incoming requests with JSON data and turns it into an object to send JSON data to the server
292
What is PostgreSQL and what are some alternative relational databases?
powerful, free, open source Relational Database Management System (RDBMS) MySQL, SQL Server by Microsoft, Oracle by Oracle Corporation
293
What are some advantages of learning a relational database?
they support good guarantees about data integrity - They can store and modify data in a way that makes data corruption as unlikely as possible
294
What is one way to see if PostgreSQL is running?
sudo service postgresql status
295
What is a database schema?
collection of tables defines how the data in relational database should be organized blueprint on how a database should look like
296
What is a database schema?
collection of tables defines how the data in relational database shoudl be organized
297
What is a table?
list of rows each having the same set of attributes i.e. all students in a "students" table could have "firstName" "lastName" and "dateOfBirth"
298
What is a row?
record in that spreadsheet
299
What is SQL and how is it different from languages like JavaScript?
SQL (structured Query Language) : primary way of interacting with relational databases declarative programming language instead of JS which is an imperative language
300
How do you retrieve specific columns from a database table?
select "" from ""
301
How do you filter rows based on some specific criteria?
select "" from "" where "" = ''
302
What are the benefits of formatting your SQL?
consistent style and readability
303
What are four comparison operators that can be used in a where clause?
<, >, =, and !=
304
How do you limit the number of rows returned in a result set?
limit integer
305
How do you retrieve all columns from a database table?
select *
306
How do you control the sort order of a result set?
order by "" desc/asc
307
How do you add a row to a SQL table?
using the insert statement
308
What is a tuple?
list of values
309
How do you add multiple rows to a SQL table at once?
separate the tuples by commas
310
How do you get back the row being inserted into a table without a separate select statement?
returning clause
311
How do you update rows in a database table?
update statement set
312
Why is it important to include a where clause in your update statements?
it might update every row in the table!
313
How do you delete rows from a database table?
delete statement where clause
314
How do you accidentally delete all rows from a table?
delete statement without stating a where clause
315
What is a foreign key?
one column that links 2 tables together
316
How do you join two SQL tables?
select statement from clause join clause - join "blank" using ("foreign key")`
317
How do you temporarily rename columns or tables in a SQL statement?
create an alias for it by using as ex: select "products"."name" as "product", "suppliers"."name" as "supplier"
318
What are some examples of aggregate functions?
max() min() avg()
319
What is the purpose of a group by clause?
separate rows into groups and perform aggregate functions on those groups of rows
320
What are the three states a Promise can be in?
pending fulfilled rejected
321
How do you handle the fulfillment of a Promise?
using a .then method
322
How do you handle the rejection of a Promise?
using a .catch method
323
What is Array.prototype.filter useful for?
creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function
324
What is Array.prototype.map useful for?
creates a new array populated with the results of calling a provided function on every element in the calling array
325
What is Array.prototype.reduce useful for?
allows you to "reduce" an array to a single value executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value
326
What is "syntactic sugar"?
syntax within a programming language that is designed to make things easier to read or to express
327
What is the typeof an ES6 class?
function
328
Describe ES6 class syntax.
declare a class with keyword class, name of class, then open curly braces initialize the properties with constructor keyword and properties in parenthesis open curly brace this.properties = proeprties
329
What is "refactoring"?
the process of restructuring existing computer code—changing the factoring—without changing its external behavior
330
What is Webpack?
a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets. module bundler
331
How do you add a devDependency to a package?
you install it using npm install
332
What is an NPM script?
a convenient way to bundle common shell commands for your project
333
How do you execute Webpack with npm run?
npm run build
334
How are ES Modules different from CommonJS modules?
syntax is even mroe compact than CommonJS structure can be statically analyzed (for static checking, optimization, etc.) Their support for cyclic dependencies is better than CommonJS’s
335
What kind of modules can Webpack support?
ECMAScript modules CommonJS modules AMD modules Assets WebAssembly modules
336
What is React?
React is a JavaScript library for creating user interfaces.
337
What is a React element?
an object representation of a DOM node
338
How do you mount a React element to the DOM?
render()
339
What is Babel?
toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments takes newer syntax and converts into a widely used syntax
340
What is a Plug-in?
software component that adds a specific feature to an existing computer program
341
What is a Webpack loader?
transformations that are applied to the source code of a module allow you to pre-process files as you import or “load” them
342
How can you make Babel and Webpack work together?
incorporate the babel loader allows them work together
343
What is JSX?
allows us to write HTML-like syntax in React a syntax extension to JavaScript
344
Why must the React object be imported when authoring JSX in a module?
internally every JSX is creating a React Component using JSX transformer
345
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
use the babel-loader and have
346
What is a React component?
independent and reusable bits of code function that takes in arbitrary inputs and returns JSX
347
How do you define a function component in React?
1. is a JavaScript/ES6 function. 2. must return a React element (JSX) 3. always starts with a capital letter (naming convention)
348
How do you mount a component to the DOM?
render method
349
What are props in React?
arguments passed into React components props stands for properties
350
How do you pass props to a component?
pass props with key value pair attributes
351
How do you write JavaScript expressions in JSX?
You can put any valid JavaScript expression inside the curly braces in JSX
352
How do you create "class" component in React?
class keyword the component's name must start with an upper case letter needs "extends React.Component" creates an inheritance to React.Component, and gives your component access to React.Component's functions needs render()
353
How do you access props in a class component?
this.props
354
What is the purpose of state in React?
states is for managing data and contains data or info about the component
355
How to you pass an event handler to a React element?
With JSX you pass a function as the event handler using camelCase, rather than lowercase inside curly braces
356
What are controlled components?
An input form element whose value is controlled by React
357
What two props must you pass to an input for it to be "controlled"?
value onChange
358
What Array method is commonly used to create a list of React elements?
map method
359
What is the best value to use as a "key" prop when rendering lists?
use a string that uniquely identifies a list item among its siblings
360
What does the acronym LIFO mean?
last-in-first-out // the last thing pushed onto the stack is the first thing that can be popped out
361
What methods are available on a Stack data structure?
push() pop()
362
What must you do to access the value at an arbitrary point in a stack (not just the "top")?
peek()
363
what in javascript uses a stack
array?
364
What does the acronym FIFO mean?
first-in-first-out (FIFO) operations: the first thing enqueued onto the queue is the first thing that can be dequeued out.
365
What methods are available on a Queue data structure?
enqueue(value) - adds a value to the "back" of the queue dequeue() - removes the "front" value from the queue and returns it peek() - returns the "front" value of the queue without removing it.
366
What must you do to access the value at an arbitrary point in a queue (not just the "front")?
Dequeue until you reach desired value
367
How are linked lists different from an array?
Linked lists are sequential access (like a queue), not random access (like an array)
368
How would you access an arbitrary node in a linked list (not just the "head")?
you have to start at the beginning, then jump from node to node until you get there