WebDev Flashcards

1
Q

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

A

An HTML list is a block-level element.

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

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

A

An unordered list is a list with bullet points. An ordered list is numbered.

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

How do block-level elements affect the document flow?

A

Block level elements push items on the same line as it down or up depending on orientation. To the left of the element means its pushed up and vice versa for items to the right.

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

How do inline elements affect the document flow?

A

Inline elements allow for other items to be on the same horizontal space as them.

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

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

A

The default height of a block level element would be the height of the the element itself. The default width of a block-level element would be the length of the web page.

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

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

A

The default height and width of an inline element would be the height and width of the element itself.

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

Give five examples of HTML element types.

A

, , <h1>, , </h1><p></p>

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

What is the purpose of HTML attributes?

A

To modify the behavior of a specific element.

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

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

A

The less-than sign ( < ) can be denoted as <

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

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

A

You put non-visible content in the element of the HTML document.

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

Where do you put visible content about the HTML document?

A

You place visible content about the HTML document in the element.

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

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

A

They go inside of the element.

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

What is the purpose of a declaration?

A

It is an instruction to the web browser about which version of HTML is being used.

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

<a> </a>

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

What is an absolute URL?

A

An absolute URL contains all the information necessary to locate a resource

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

What is a relative URL?

A

A relative URL locates a resource using an absolute URL as a starting point. Generally used to link to resources within the same website.

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

You use the ../ to indicate the folder above the current one. EX. href=”../index.html”

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.
EX. href=”music/listings.html”

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

You use two of the ../ operator in the file address.
EX. href=”../../index.html”

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

You only need to use the file name. There are no other things needed.
EX. href=”reviews.html”

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

It is a document section that allows for users to submit information

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, select, textarea, button, a

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

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

A

Inline-Block

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

password, image, text

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

What are the six primary HTML elements for creating tables?

A

table, tr, td, th, tbody, thead

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

What purpose do the thead and tbody elements serve?

A

The thead serves as a container for the headings of the table. The tbody serves as a container for the body of the table

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

Give two examples of data that would lend itself well to being displayed in a table.

A

Sports results and financial reports both lend themselves to being displayed in a table.

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

What are the names of the individual pieces of a CSS rule?

A

A CSS rule consists of a selector and a declaration. Each line in the declaration block has a property and a value.

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

In CSS, how do you select elements by their class attribute?

A

Similar to a type selector, however you add a . in front of the class name.
EX. .note {}

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

In CSS, how do you select elements by their tag name?

A

You simply put the name of the tag that you wish to affect.
EX. h1, h2, h3 {}

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

In CSS, how do you select an element by its id attribute?

A

You would add a # in front of the tag that you would like to affect.
EX. #introduction {}

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

Name three different types of values you can use to specify colors in CSS.

A

RGB values, Hex codes, and Color names

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

What CSS properties make up the box model?

A

Margins, Borders, Padding, Content of box.

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

Which CSS property pushes boxes away from each other?

A

Margin

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

Which CSS property add space between a box’s content and its border?

A

Padding

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

What is a pseudo-class?

A

A keyword that allows for styles to be applied to an element only under specific circumstances.

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

What are CSS pseudo-classes useful for?

A

They are useful for denoting an element in a special state.

For example, a button can have a pseudo class that makes the button feel more like it is being pressed by changing the style or position of the element slightly

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

Name two types of units that can be used to adjust font-size in CSS.

A

You can use percentages or EM’s

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

What CSS property controls the font used for the text inside an element?

A

font-family

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

What is the default flex-direction of a flex container?

A

In a row

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

What is the default flex-wrap of a flex container?

A

No Wrap is the default, namely, all items will try and be on one single line.

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

Why do two div elements “vertically stack” on one another by default?

A

They are default Block

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

What is the default flex-direction of an element with display: flex?

A

Flex Row

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

What is the default value for the position property of HTML elements?

A

Position: static

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

How does setting position: relative on an element affect document flow?

A

The element can now move in relation to where it would have been in normal flow. However, you can now move the element around the page.

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

How does setting position: relative on an element affect where it appears on the page?

A

Depending on offset properties, The image can be moved in relation to where it originally would have been in normal flow.

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

How does setting position: absolute on an element affect document flow?

A

The element is removed from normal flow and no long affects the position of other elements on the page. The other elements act as if the element doesnt exist.

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

How does setting position: absolute on an element affect where it appears on the page?

A

It appears relative to its nearest non-static ancestor.

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

How do you constrain an absolutely positioned element to a containing block?

A

You constrain it to the box of its nearest ancestor element.
Make the nearest ancestor element not static in positioning.

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

What are the four box offset properties?

A

top, bottom, left, and right.

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

What is the purpose of variables?

A

A way to store data so you can see it, manipulate it, etc. Adds permanence to data.

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

How do you declare a variable?

A

var variableName;

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

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

A

var hasName = true;

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

What characters are allowed in variable names?

A

Letters, numbers, dollar signs, underscores. However, variables cannot start with a number.

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

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

A

Capital letters matter in the naming of variables.

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

What is the purpose of a string?

A

For storing and manipulating text/a set of characters. JS will not interpret this as code.

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

What is the purpose of a number?

A

For counting, measuring, or for seeing the numerical value of something.

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

What is the purpose of a boolean?

A

To measure if something is true or false, used for decision making.

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

What does the = operator mean in JavaScript?

A

This is the assignment operator. Whatever data is being declared will be stored inside of the variable.

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

How do you update the value of a variable?

A

To update a variable you only need to omit the var keyword :
var something = 8
something = 7
The value of variable something is now 7

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

What is the difference between null and undefined?

A

Null is a value that does not exist, a placeholder of sorts. Null is a value that can only be assigned. When you see null, a developer purposely set it as such.

Undefined is javascripts automatic way of saying empty. If you declare a variable without a value, JS reads it as undefined. As a developer, you should never use undefined.

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

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

A

It can be difficult in longer projects to remember what a variables name or value is.

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

Give five examples of JavaScript primitives.

A

string, number, null, undefined, boolean

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

What data type is returned by an arithmetic operation?

A

A number data type.

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

What is string concatenation?

A

The combination of two strings to form one string.

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

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

A

It is the arithmetic operator for addition and it is used to add one value to another.

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

What data type is returned by comparing two values (<, >, ===, etc)?

A

A boolean data type.

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

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

A

The plus equals operators adds two number values together and then assigns the resulting number to a variable.

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

What are objects used for?

A

They are used to store multiple variables into a single container with one name (an object)

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

What are object properties?

A

Object Properties are variables that are defined under an object.

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

Describe object literal notation.

A

Object literal notation is when the object properties are directly defined inside of the object declaration

var object = {
property: propertyValue,
property2: propertyValue2
}

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

How do you remove a property from an object?

A

use the delete operator.
Delete student.firstName

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

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

A

object.property
object[‘property’]

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

What are arrays used for?

A

It is used to store a collection of data, a list of sorts

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

Describe array literal notation.

A

[index1, index2,…]

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

How are arrays different from “plain” objects?

A

When adding to an array, we use the method push.
When adding to an object, we use dot or bracket notation and assign it a value.
Arrays also have a length property.

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

What number represents the first index of an array?

A

0

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

What is the length property of an array?

A

styled as array.length, the length property returns the number of items inside of the array. Automatically kept up to date.

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

How do you calculate the last index of an array?

A

You would use the length keyword and then subtract 1 off of that value.
array[0, 1, 2, 3]
array.length = 4
lastIndex = array.length - 1 (This is equal to 3)
length[lastIndex] will return 3 I.e. length[3]

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

What is a function in JavaScript?

A

A set of statements that do a task or calculate a value. It can also be reused.

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

Describe the parts of a function definition.

A

Starts with a function keyword, has a function name, a comma separated list of parameters in parenthesis, Then there is the function code block separated by curly braces, an optional return statement.

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

Describe the parts of a function call.

A

Name of the function, arguments located in the comma spaced parentheses.

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

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

A

A function call is just the name of the function with whatever arguments you wish to place into the function. In a function definition, the arguments are known as parameters and there is a placeholder parameter along with the definition of the actual function within curly braces. The function keyword is also present in a definition

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

What is the difference between a parameter and an argument?

A

A parameter is found in a function definition, an argument is used when the function is actually being called.

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

Why are function parameters useful?

A

Without them you lose the re-usability of functions. They allow us to use a function for multiple different situations.

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

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

A

The return statement ends the function execution and also returns a value to the user.

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

Why do we log things to the console?

A

Gives us a way to observe and communicate with our code.

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

What is a method?

A

It is a property of an object that contains a function definition.

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

How is a method different from any other function?

A

A method is specifically defined inside of an object. It is also technically a property of an object. To call a method you need to provide the context of its call.
ex. arr.pop()

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

How do you remove the last element from an array?

A

By using the .pop() method. The syntax would be arr.pop()

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

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

A

By using the Math.floor() method.

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

How do you generate a random number?

A

You would use the Math.random() method.

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

How do you delete an element from an array?

A

You could use the .splice method.

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

How do you append an element to an array?

A

You could use the .push() method

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

How do you break a string up into an array?

A

You would use the .split() method.

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

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

A

The string methods don’t change the original string specifically. You could console.log it to see if it has. Strings are immutable in JavaScript

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

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

A

50?

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

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

A

No, not always. Often times, we want to delete something and we just want to make sure that thing has been removed.
I.e .pop() method

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

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

A

A ton, like 50.

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

What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?

A

MDN (Mozilla Developing Network)

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

Give 6 examples of comparison operators.

A

Equal to: ===
not equal to: !=
Greater than: >
Less than: <
Greater than or equal to: >=
Less than or equal to: <=

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

What data type do comparison expressions evaluate to?

A

Boolean data types

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

What is the purpose of an if statement?

A

An if statement provides a conditional for the code to make a decision.

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

Is else required in order to use an if statement?

A

No it is not.

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

Describe the syntax (structure) of an if statement.

A

if (score >= 50) {
congratulate();
}

if = keyword
(score >= 50) = condition
code block = code that will be executed if the condition is filled

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

What are the three logical operators?

A

And Operator = &&
Logical Or operator = ||
Logical Not = ! (inverts boolean value)

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

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

A

You would link them with the && or the || operator

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

What is the purpose of a loop?

A

They are used to repeatedly run a block of code until a condition is met

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

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

A

The condition expression gives the loop the parameters it needs in order to stop the loop

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

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

A

Each pass through the block of code is called an iteration

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

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

A

It is evaluated prior to the execution of the statement and prior to each iteration.

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

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

A

It is evaluated once before the start of the loop. Before the first iteration.

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

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

A

The condition expression is evaluated at the start of an iteration.

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

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

A

The final expression is executed at the end of an iteration.

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

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

A

The break keyword.

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

What does the ++ increment operator do?

A

It adds one to its operand and returns the new value.

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

How do you iterate through the keys of an object?

A

You would use bracket notation paired with a for…in loop
I.E
function valuesFromKeys(object) {
var keys = [ ];
for( var x in object) {
keys.push(x);
}
return keys;
}

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

What are the four components of “the Cascade”.

A

Importance, Specificity, Source Order, !important

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

What does the term “source order” mean with respect to CSS?

A

Source order is the order in which CSS will display new stylings dependent on the order in which they are written in the stylesheet

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

How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?

A

When dealing with nested elements, when you apply a CSS styling to the parent element and there is no styling specified for the child element, the child will receive the same styling as the parent.

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

List the three selector types in order of increasing specificity.

A

Type selector, class selector, ID selector

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

Why is using !important considered bad practice?

A

Because it directly ignores the rules of CSS Specificity

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

What does the transform property do?

A

It allows you to scale, skew, rotate, or translate an element.

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

Give four examples of CSS transform functions.

A

Rotate, translate(Y), scale, skew

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

The transition property is shorthand for which four CSS properties?

A

Transition-property, transition-duration, transition-timing-function, transition-delay

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

Why do we log things to the console?

A

To communicate with our code and see how it is doing.

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

What is a “model”?

A

It is a rendition or a replica of something.

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

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

A

The document is the actual webpage itself. The HTML document.

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

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

A

The object in DOM refers to the nodes and objects that the webpage gets broken up into.
The JavaScript Objects.

The DOM realistically is JavaScript Objects that are representing the HTML document.

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

What is a DOM Tree?

A

It is a model of an element and all of its configurations and all of the contents contained.

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

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

A

.getElementByID( ) and .querySelector( )***

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

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

A

.querySelectorAll( )

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

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

A

So that you can reuse it in different scenarios.

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

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

A

console.dir( )

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

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

A

The browser needs to parse through all of the HTML elements before we can access them with JavaScript

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

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

A

It takes in a CSS selector as its argument and it returns the first matching element that it finds.

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

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

A

It takes a CSS selector as an argument and it returns a Node list of all the matching elements that it finds. A node list is not a DOM element, it is an object that stores DOM elements.

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

What is the purpose of events and event handling?

A

The purpose of events is so that the webpage can react to specific things that may occur from the user. Event handling is a routine that is performed when the event that is being watched for occurs.

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

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

A

No

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

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

A

element.addEventListener( )

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

What is a callback function?

A

A callback function is when one function is passed into another function as an argument.

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

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

A

The event object itself. Its contents are all of the data about said event.

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

What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?

A

Event.target is a reference to the exact element in which the event affects. If I wasnt sure I could log event.target and see what comes out. You could also check MDN.

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

What is the difference between these two snippets of code?
element.addEventListener(‘click’, handleClick)
element.addEventListener(‘click’, handleClick())

A

The first snippet calls the function as an argument or a callback function.
The second snippet actually calls the function itself without any parameters which will result in a return value for said function.

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

1) Never call an event handler function yourself

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

What is the className property of element objects?

A

The className property of an element gets or sets the value of the name of the class.

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

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

A

You would use the className method.
EX
$someDOMvar.className = ‘new class name’

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

What is the textContent property of element objects?

A

It is a property that returns all the text content of the element and all of its descendents.

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

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

A

You would use the textContent method.
EX.
$domVar. textContent = ‘new text content’

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

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

A

No. Because there are instances where you do not want variability in your event handler functions.

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

Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?

A

I feel like it would be more difficult. The counter helped me track where I was in terms of amount of clicks.

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

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

A

The DOM is only temporary and is applicable to only the instance of the webpage. Once you refresh it you restart to the beginning. There is also a security concern. Its better to have a variable to work off of instead of relying on output.

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

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

A

focus

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

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

A

Blur

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

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

A

input

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

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

A

submit (on the form element, not on the button itself)

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

What does the event.preventDefault() method do?

A

If the event is not specifically handled, it should not take its normal default action.

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

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

A

It will just refresh the page. ALWAYS include a preventDefault in your submit event listener

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

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

A

HTML form elements

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

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

A

the .values property

161
Q

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

A

If you run into a bug that occurred early on in the code and theres a bug, youll have to go through more debugging than if you just checked as you worked.

162
Q

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

A

You can test and see if the javascript is doing the things to the Web Document the way you want it to.

163
Q

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

A

No not immediately, it still needs to be appended to the parent element.

164
Q

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

A

parentElement.appendChild(childElement)

165
Q

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

A

You would pass two strings. The first would be the attribute you wish to set, and the second would be the value of the attribute.

166
Q

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

A

1) Create the element.
2) Create and append any textContent or Attributes.
3) append the new element to a parent element. (after query selecting)

167
Q

What is the textContent property of an element object for?

A

It is used to either retrieve or set the text content of an element.

168
Q

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

A

one would be to use the .setAttribute(‘class’, ‘xxx’)
You could also use element.ClassName

169
Q

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

A

You can return the same function to do different jobs. You can also reuse the function multiple times.

170
Q

Give two examples of media features that you can query in an @media rule.

A

width and height

171
Q

Which HTML meta tag is used in mobile-responsive web pages?

A

The viewport HTML meta tag

172
Q

What is the event.target?

A

The property of the event object that holds the element where the event originated from.

173
Q

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

A

Because the default for JS is for the event listener to have a bubbling effect.

174
Q

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

A

the element.tagName property. = Actual name of the element in FULL CAPS

175
Q

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

A

The argument takes the selector that we are looking for. It returns the closest ancestor that fits the argument. It is the opposite of querySelector, it looks outward.

176
Q

How can you remove an element from the DOM?

A

You use the .remove() method.

177
Q

If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?

A

Youd use Event Delegation. Put it on an ancestor and use closest to look for instances from within the parent element.

178
Q

What is the event.target?

A

The property of the event object that holds the element where the event originated from.

179
Q

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

A

The element disappears from the page. It doesnt even save space for where it would be.

180
Q

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

A

It takes the selector that you wish to compare against. It returns a boolean.

181
Q

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

A

You can use the getAttribute() method

182
Q

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

A

When checking to see what the event.target value is. When checking to see the attribute. Or checking to see if the .matches method is returning the proper boolean. Any time you have comparisons or you are calling a method on an object.

183
Q

If you were to add another tab and view to your HTML, but you didn’t use event delegation, how would your JavaScript code be written instead?

A

You would have to make an event listener for the new tab. Along with new event listeners for every other tab as well.

184
Q

If you didn’t use a loop to conditionally show or hide the views in the page, how would your JavaScript code be written instead?

A

Youd most likely need to write separate if statements for each individual tab in order to change the views on the page.

185
Q

What is a breakpoint in responsive Web design?

A

The point in which a website will adjust and adapt in accordance to the code in order for the user to have a more positive experience.

186
Q

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?

A

This allows for the column class to stay relatively the same regardless of the size of the viewport. As the viewport shrinks or grows, percentages will allow for the elements to stay in relatively the same position.

187
Q

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?

A

The Source Order of cascade. You want to reduce the influence of source order and let the cascade do its job.

188
Q

What is JSON?

A

JSON stands for Javascript Object Notation. It is a text based format used to represent data. It takes the form of a javascript object literal. It is most commonly used to transmit data to web apps.

189
Q

What are serialization and deserialization?

A

Serialization is effectively the conversion of something into a series of 1’s and 0’s (binary code). Deserialization is the opposite, it is the construction of something out of binary code.

190
Q

Why are serialization and deserialization useful?

A

Serialization allows us to convert temporary object data into bytes which allows us to store it on the hard drive for long term storage. Deserialization allows for us to take these serialized objects and convert them back into object data again.

191
Q

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

A

You would use the method JSON.stringify( )

192
Q

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

A

You would use the JSON.parse( ) method.

193
Q

How do you store data in localStorage?

A

You would use localStorage.setItem( )
Kebab case for keys

194
Q

How do you retrieve data from localStorage?

A

Youd use the localStorage.getItem( ) method

195
Q

What data type can localStorage save in the browser?

A

It can save data with the string data type.

196
Q

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

A

It fires when the window, the document, and its resources are about to be unloaded.

197
Q

What is a method?

A

A method is a function that is also a property of an object.

198
Q

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

A

The method definition will usually be in an object literal and will only have the name of the function with its parameters.
A method call will have the object its attached to in front of it in dot notation.
EX. calculator.getSum(1, 2)

199
Q

Describe method definition syntax (structure).

A

var newObj = {

function(para) {
definition
},

function(para) {
definition
}

}

200
Q

Describe method call syntax (structure).

A

objectName.function(arg);

201
Q

How is a method different from any other function?

A

A method is actually a function that is a property of an object. Any other function exists outside of an object.

202
Q

What is the defining characteristic of Object-Oriented Programming?

A

The pairing of data (properties) and behavior (methods) together in a single object.

203
Q

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

A

Abstraction : the generalization of data
Encapsulation: the bundling of data with methods that will interact with it
Inheritance: basing a class or object upon previously existing objects or classes
Polymorphism: the use of a single symbol to represent multiple data types

204
Q

What is “abstraction”?

A

The generalization of complex data and adding it to a simple interface. “Being able to work with potentially complex things in simple ways”.

205
Q

What does API stand for?

A

Application Programming Interface

206
Q

What is the purpose of an API?

A

In regards to OOP, an API is a description of how objects work in a given object oriented language. Abstractions created in order for you to interact with complex systems.

207
Q

What is this in JavaScript?

A

‘this’ is a keyword in javascript. Depending on the time in which it is used, it can represent many things. However, it is most commonly used to represent the object that is being worked in.

208
Q

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

A

It means that ‘this’ is available in a functions codeblock even if it does not appear in the parameter list or is not being defined as a variable.

209
Q

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

A

The value of ‘this’ is determined by call time.

210
Q

What does this refer to in the following code snippet?
var character = {
firstName: ‘Mario’,
greet: function () {
var message = ‘It's-a-me, ‘ + this.firstName + ‘!’;
console.log(message);
}
};

A

‘this’ does not even exist yet because the greet method is not being called.

211
Q

var character = {
firstName: ‘Mario’,
greet: function () {
var message = ‘It's-a-me, ‘ + this.firstName + ‘!’;
console.log(message);
}
};

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

character.greet();

A

character.greet() will console log the message “It’s a me, Mario!”
(this.firstName = ‘Mario’)

212
Q

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

var hello = character.greet;
hello();

A

This will console log “Its-a-me, undefined!” because ‘this’ is currently undefined because its being called outside of the object.

213
Q

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

A

because the function that holds ‘this’ has not been called yet, we cannot say what ‘this’ means definitively.

214
Q

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

A

You would need to look to the left of the dot operator of the method call. If there is nothing there, then it is window.

215
Q

What kind of inheritance does the JavaScript programming language use?

A

Javascript uses Prototype-based or prototypal inheritance. Which is when javascript objects are able to give behaviors (methods) or data (variables) to other javascript objects.

216
Q

What is a prototype in JavaScript?

A

A prototype is an object that has methods and variables that can be inherited by other objects.

217
Q

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

A

Because strings, arrays, and numbers have prototypes that have the methods that are being used on them.

218
Q

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

A

Javascript goes and looks for it in the object prototype that applies to the object.

219
Q

What does the new operator do?

A

The new operator creates an instance of a user-defined object type or prebuilt object type (array, function, string)
1. Creates new blank, plain object
2. Points new instances prototype to the constructor functions prototype property
3. Executes the constructor function with the given arguments and bind the new instance as ‘this’
4. If the constructor returns a non-primitive, the return value becomes the result of the ‘new’ expression.

The purpose of a constructor is to help us get access to the actualy prototype which houses all the methods / data

220
Q

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

A

The prototype property allows for sharing of data and methods between instances of the same object.

221
Q

What does the instanceof operator do?

A

The instanceof operator checks to see if any given object is an instance of a prototype.

222
Q

What is a “callback” function?

A

It is a function that is called as an argument to another function

223
Q

Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?

A

You could put the function that you wish to perform in the global method setTimeout() with the function and the millisecond delay you wish.

224
Q

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

A

You could use the setInterval method, passing in the function and the time between each function call.

225
Q

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

A

It automatically sets to 0 if no delay is given.

226
Q

What do setTimeout() and setInterval() return?

A

They return an IntervalID which identifies the interval. This allows for the user to stop the interval using the clearInterval method.

227
Q

What is a client?

A

A piece of hardware or software that accesses services provided by a server.
(Requests resources from servers)

228
Q

What is a server?

A

A piece of hardware or software that provides functionality to requesting clients

229
Q

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

A

GET method

230
Q

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

A

1) An http method (GET, PUT, POST, etc)
2) The request target (usually a URL)
3) The HTTP version

231
Q

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

A

1) The protocol version (usually HTTP 1.1)
2) A status code, indicating failure or success
3) A status text to allow the user to understand the HTTP message.

232
Q

What are HTTP headers?

A

They allow for the client and the server to pass along additional information with an HTTP request or response.

233
Q

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

A

MDN

234
Q

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

A

Not always. HTTP methods like GET, HEAD, DELETE, or OPTIONS dont need one.

235
Q

What is AJAX?

A

A programming practice of building dynamic webpages using XMLHttpRequest.
The act of grabbing data, adding data, all asynchronously.

236
Q

What does the AJAX acronym stand for?

A

Asynchronous Javascript And XML

237
Q

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

A

XMLHttpRequest

238
Q

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

A

The load event

239
Q

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

A

They share the same prototype (EventTarget)

240
Q

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

A

A code block is a grouping of code grouped together by curly braces. An example of a code block would be in a function definition.
function () {
codeblock
}

241
Q

What does block scope mean?

A

Block scope means that variables only exist within that code block

242
Q

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

A

Const and Let variables are block scoped

243
Q

What is the difference between let and const?

A

Unlike let variables, const variables cannot be reassigned once they are declared

244
Q

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

A

Const cannot be changed through reassignment or redeclaration. .push() only adds onto the already existing array.

245
Q

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

A

It all depends on what you are going to do with the variable. If you don’t need to reassign it you should use const, but if you need to reassign the variable you should use let.

246
Q

What is the syntax for writing a template literal?

A

backticks would bookend the string, if youd like to add variables you would add ${}
I.e.
My name is Markus or My name is ${firstName}

247
Q

What is “string interpolation”?

A

The process in which an expression is inserted or placed into a string.

248
Q

What is destructuring, conceptually?

A

It is the act of unpacking or breaking down data structures to retrieve their individual values and the assigning those values to variables

249
Q

What is the syntax for Object destructuring?

A

const {property1, property2, property3} = obj ,
const {property1: prop1, property2:prop2} = obj

250
Q

What is the syntax for Array destructuring?

A

const [ element1, element2, element3 ] = newArr

251
Q

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

A

The big difference is what is on either side of the assignment operator (=). If the object/array literal looks to be on the left with the variable name on the right it is being destructured, if it is swapped, then its being created.

252
Q

What is the syntax for defining an arrow function?

A

let newFunction = (arg1, arg2, … argN) => {statement/s}
one arg:
const newFunc = arg1 => {statement/s}
no arg:
const newFunc = () => {statement/s}

253
Q

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

A

The function now has an implicit return. It will return the expression even without the use of the return keyword

254
Q

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

A

It looks at the scope surrounding it. (Lexical Scope)
The value of this is determined WHERE it is defined.

255
Q

What is a CLI?

A

Command-Line Interface, text-based way to talk to a program

256
Q

What is a GUI?

A

Graphical User Interface

257
Q

Give a use case for ‘man’

A

When youd want to look into more information about a CLI command

258
Q

Give a use case for ‘cat’

A

When you want to print out the contents of a text file.

259
Q

Give a use case for ‘ls’

A

When you want to list the contents of a directory

260
Q

Give a use case for ‘pwd’

A

When you want to print the current directory that you are in

261
Q

Give a use case for ‘echo’

A

When youd like to display a line of text in the Command Terminal

262
Q

Give a use case for ‘touch’

A

Technically you would use it when you want to modify a timestamp, but many use it to create new files.

263
Q

Give a use case for ‘mkdir’

A

When you’d want to make a new directory

264
Q

Give a use case for ‘mv’

A

For when youd like to rename (effectively, move) a file.

265
Q

Give a use case for ‘rm’

A

When youd like to remove a file or a directory

266
Q

Give a use case for ‘cp’

A

Whenever you would want to copy a file or directory

267
Q

Give a use case for ‘history’

A

When you want to see or save your command line history

268
Q

What are the three virtues of a great programmer?

A

Laziness, Impatience, and Hubris

269
Q

What is node.js?

A

You can run javascript outside of the browser

270
Q

What can Node JS be used for

A

Backends for web apps, cmd line programs, automation

271
Q

What is a REPL?

A

Read-Eval-Print-Loop
Reads the javascript, evaluates it, prints it out. Used in programming languages.

272
Q

When was Node.js created?

A

2009

273
Q

What back end languages have you heard of?

A

Java, Ruby, Rust, Python, SQL, C#, Golang, JavaScript, C++, C

274
Q

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

A

The process object is a global variable that provides information and control on the current Node.js process. Process = instance of a running program

275
Q

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

A

The process object can be accessed directly because it is a global variable. You can also access it with the syntax:
const process = require(‘process’)

276
Q

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

A

It is an array of strings

277
Q

What is a JavaScript module?

A

A file containing a function or a group of similar functions. They often contain code that can execute specific tasks when called into a larger application.

278
Q

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

A

exports, require, module, __dirname, __filename

279
Q

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

A

global and console

280
Q

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

A

It allows for us to achieve modular programming because it allows for us to split functionality to different files. Sends whatever variables/functions we want to share.

281
Q

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

A

You would have to make sure that the functionality that you want has been assigned to module.exports. You would then create a variable which would be assigned required(‘./otherFile’)

282
Q

What is the JavaScript Event Loop?

A

The Javascript event loop is used when the stack is clear but there are items inside of the task queue. The event loop will grab the first item out of the task queue and put it onto the stack to be executed.

283
Q

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

A

Blocking is when the code is being run synchronously on the call stack. Non-blocking is when the code is run asynchronously off of the call stack so multiple things can occur simultaneously

284
Q

What is a directory?

A

A directory is a file that holds other files

285
Q

What is a relative file path?

A

A relative path is one that refers to a locations in relation to the current working directory. Generally used with ./ or ../

286
Q

What is an absolute file path?

A

The specific location of a file starting with the root directory

287
Q

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

A

They incorporate the file system module or fs

288
Q

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

A

.writeFile()

289
Q

Are file operations using the fs module synchronous or asynchronous?

A

It would depend on what method you would use from the fs module. .readFile and .writeFile are both asynchronous

290
Q

What is a client?

A

A client is something that requests content or services from a server.

291
Q

What is a server?

A

Provider of a resource or service

292
Q

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

A

It sends the GET method

293
Q

What is on the first line of an HTTP request message?

A

A http method(GET, PUT, POST, etc, and then the URL of the website you wish to request from (request target)

294
Q

What is on the first line of an HTTP response message?

A

The status line. Contains the protocol verson, a status code indicating success or failure, and then status text which tells the user what the status code means

295
Q

What are HTTP headers?

A

The header for both request and responses both contain metadata and context about the request/response

296
Q

Is a body required for a valid HTTP message?

A

No. Depending on what you wish to do with your request there often is no body. Methods like GET requests dont need bodies.

297
Q

What is NPM?

A

NPM is a package manager that is effectively a software registry that houses thousands of packages or modules for use.
Website
Registry
CLI

298
Q

What is a package?

A

A package is something that contains a file with everything that youd need for a module. (Directory with 1 or more file + package.json)

299
Q

How can you create a package.json with npm?

A

you would use the command line
npm init –yes

300
Q

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

A

A dependency is a code from a third party that a package needs to work. To add one you would use the command line npm install ‘dependency’

301
Q

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

A

The dependency appears on your package.json file. Also, a node-modules file appears in your local directory

302
Q

How do you add express to your package dependencies?

A

you would use on the command line ‘ npm install express’

303
Q

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

A

The listen() method

304
Q

How do you mount a middleware with an Express application?

A

You would use .use()

305
Q

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

A

The res and req objects

306
Q

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

A

application/json;

307
Q

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

A

The HTTP request method indicates intent from the client and also a label for what the method actually does

308
Q

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

A

express.json() takes in incoming request in JSON and parses it. You would need it if someone was trying to post some JSON data.

309
Q

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

A

express.json() takes in incoming request in JSON and parses it. You would need it if someone was trying to post some JSON data.

310
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is an open source relational database. Relational databases stores data and sorts them by predefined relationships. Some other relational databases would be Microsoft SQL server, Firebird, and Helix

311
Q

What are some advantages of learning a relational database?

A

Many domains can be modeled well with relational databases. Relational databases also support good data integrity. Learning relational databases are transferable skills

312
Q

What is one way to see if PostgreSQL is running?

A

You can use the command: sudo service postgresql status

313
Q

What is a database schema?

A

A schema is a definition to how data in a relational database should be organized and stored

314
Q

What is a table?

A

A table is data being stored in a relation. The table has rows and columns. Each individual row is an entry into the table. Each column is an attribute that each entry can have

315
Q

What is a row?

A

A row is a record in the spreadsheet. Each row is made up of columns that represent attributes for each row.

316
Q

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

A

SQL is a language used primarily to communicate with databases. It differs from languages like JavaScript because it is a declarative language which means we tell SQL what we want vs an imperative language where we have to tell it exactly how to do what we want.

317
Q

How do you retrieve specific columns from a database table?

A

You would use the select key word with the name of the columns youd like to see in double quotes.
EX.
select “firstName”

318
Q

How do you filter rows based on some specific criteria?

A

You would use the where keyword along with whatever condition youd like
EX.
select *
from “server”
where “firstName” = ‘Don’

319
Q

What are the benefits of formatting your SQL?

A

It helps to make the query more readable. It effectively ‘beautifies” our query

320
Q

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

A

= , < , > , !=

321
Q

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

A

You would use the keyword limit and then the amount of entries youd like.
EX:
limit 5;

322
Q

How do you retrieve all columns from a database table?

A

You would use the asterisk character
EX:
select *
from “server”;

323
Q

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

A

You can use the order by keywords. By default order by is in ascending order. To get it to show in descending order you would use the desc keyword.
EX:
select *
from “server”
order by “price” desc

324
Q

How do you add a row to a SQL table?

A

You would use the insert into clause.
EX:
insert into “server” (“value1”, “value2”)
values (‘data1’, ‘data2’)
returning *

325
Q

What is a tuple?

A

In SQL, a tuple is a list of values.

326
Q

How do you add multiple rows to a SQL table at once?

A

You would just need multiple tuples defined.
EX:
insert into “server” (“firstName”, “lastName”)
values (‘Markus’, ‘Doan-Le’),
(‘Andrew’, ‘Kao’)
returning *

327
Q

How do you get back the row being inserted into a table without a separate select statement?

A

You would need to use the returning clause along with the * or the column you want back
EX:
returning *

328
Q

How do you update rows in a database table?

A

You would use the update clause in the following context:
EX:
update “nameOfTable”
set “firstName” = ‘first’,
“lastName” = ‘last
where “firstName” = ‘spanky’
returning *;

329
Q

Why is it important to include a where clause in your update statements?

A

If you dont, you will change every single row in the table
EX:
update “nameOfTable”
set “firstName” = ‘first’
returning *;

This will change every firstName attribute for each row to ‘first’

330
Q

How do you delete rows from a database table?

A

You would use the delete clause
EX:
delete from “tableName”
where “firstName” = ‘Leticia’

331
Q

How do you accidentally delete all rows from a table?

A

By not including the where clause.
EX;
delete from “tableName”;

OOPS, the rows inside of tableName are gone

332
Q

What is a foreign key?

A

The shared data value between the two tables. That is used to link them.

333
Q

How do you join two SQL tables?

A

You would find a column that they have in common and the would use the join/using clause with the shared column name.
EX:
select “firstName”
from “students”
join “course” using (“studentId”)

334
Q

How do you temporarily rename columns or tables in a SQL statement?

A

You would use the as clause to create aliases
EX:
select “students”.”name” as “studentName”
from “students”

335
Q

What are some examples of aggregate functions?

A

sum( ) , count( ), avg( ), max( ), min( ), every( ), json_agg( )

336
Q

What is the purpose of a group by clause?

A

Separate rows into groups and then perform aggregate functions on those groups.

337
Q

What are the three states a Promise can be in?

A

Pending: In its initial state, it is neither fulfilled or rejected.
Fulfilled: The operation was completed successfully
Rejected: The operation failed

338
Q

How do you handle the fulfillment of a Promise?

A

You would use the Promises.prototype.then() method

339
Q

How do you handle the rejection of a Promise?

A

You would use the Promises.prototype.catch() method

340
Q

What is Array.prototype.filter useful for?

A

Its useful for when you want to create an array that has data that fits a certain parameter

341
Q

What is Array.prototype.map useful for?

A

When you need an array that has all of its elements affected by function

342
Q

What is Array.prototype.reduce useful for?

A

For when you want to combine all elements into a single value

343
Q

What is Webpack?

A

Webpack is a javascript module bundler. It even supports images, stylesheets, and fonts. It takes multiple modules and puts out fewer files (possibly even one)

344
Q

How do you add a devDependency to a package?

A

You would use npm install packagename –save-dev

345
Q

What is an NPM script?

A

A command line command with a nickname. It helps to automate multiple actions into a single command line command

346
Q

How do you execute Webpack with npm run?

A

You would npm run build on the command line.

347
Q

What is “syntactic sugar”?

A

Syntax within a programming language that makes things easier to read or express

348
Q

What is the typeof an ES6 class?

A

It is a function

349
Q

Describe ES6 class syntax.

A

Key word class, name of class, curly braces, constructor, methods
EX.
class Pizza {
constructor(isAPizza) {
this.isAPizza = isAPizza
}

topping() {
}
}

350
Q

What is “refactoring”?

A

Restructuring code without changing functionality

351
Q

How are ES Modules different from CommonJS modules?

A

CommonJS modules are synchronous which means they may cause blocking. ES modules are asynchronous. ES modules are official. CommonJS modules are a community effort

352
Q

What kind of modules can Webpack support?

A

ECMAScript modules, CommonJS Modules, and AMD modules (asynchronous module definition)

353
Q

What is React?

A

A JavaScript library used to create interfaces

354
Q

What is a React element?

A

Objects that you want to see on the screen. Not real DOM elements.

355
Q

How do you mount a React element to the DOM?

A

You would use the ReactDOM.render() method, passing in what youd want to mount to the DOM
1. Query for actual dom element
2. CreateRoot using .createRoot
3. call .render method on root passing in what you want to mount.

356
Q

What is Babel?

A

A JavaScript compiler that turns ES6 backwards compatible in older or newer browsers.

357
Q

What is a Plug-in?

A

Software that adds new features or extends functionality

358
Q

What is a Webpack loader?

A

A transformation that is applied to the source code of the module

359
Q

How can you make Babel and Webpack work together?

A

You install babel-loader into your dev dependencies using NPM. This allows webpack to bundle up jsx files and gives it to babel to transform it and then return it to webpack.

360
Q

What is JSX?

A

A javascript syntax extension that allows for us to embed javascript into html elements. It is not HTML!

361
Q

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

A

It is because JSX is effectively creating a React component using the JSX transformer

362
Q

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

A

You would use the babel-loader with the plugin for translating jsx into react

363
Q

What is a React component?

A

Conceptually, React components are like JavaScript functions. They accept props and they return React elements that mimic HTML elements. They are reusable.

364
Q

How do you define a function component in React?

A

It would be defined similarly to a JavaScript function:
function TestComponent (props) {
return React ELEMENT
} name must be capitalized

365
Q

How do you mount a component to the DOM?

A

You would use the ReactDOM.render() method, passing in what youd want to mount to the DOM
1. Query for actual dom element
2. CreateRoot using .createRoot
3. call .render method on root passing in what you want to mount.
4. Generally we will be passing in a react component

366
Q

What are props in React?

A

A JavaScript object that stores the value of attributes of a React element. Short for ‘properties’

367
Q

How do you pass props to a component?

A

prop name, equal sign, then prop value. If the value is not a string it needs to be in a set of curly braces

368
Q

How do you write JavaScript expressions in JSX?

A

To write JavaScript expressions inside of JSX we need to bookend our desired javascript expressions with curly braces
EX.
{props.text}

369
Q

How do you create “class” component in React?

A

You would use this syntax:
class CustomElement extends React.Component {
render() {
return React element
}
}

370
Q

How do you access props in a class component?

A

Inside of the class component, when you are defining the render method you would use the this object in order to access props

371
Q

What is the purpose of state in React?

A

Data model of values that change over time. “What changed in the state of the world?”

372
Q

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

A

You would pass it in as a prop and set the value to the method and bind it
EX. onClick = { this.handleClick}

373
Q

What are controlled components?

A

When a form’s data is handled by the component’s state

374
Q

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

A

the value and onChange props

375
Q

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

A

The .map array method

376
Q

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

A

A string that uniquely identifies the item, like an id

377
Q

What does express.static() return?

A

It returns a function

378
Q

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

A

It is the absolute path of the directory that contains the currently executing file.

379
Q

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

A

It joins the specified path segments into a single file path.

380
Q

What does fetch() return?

A

It returns a Promise that resolves into a response object.

381
Q

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

A

GET

382
Q

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

A

You would pass in an object that would have the desired method on it.
EX:
fetch(“API URL”, {method: “POST”})

383
Q

When does React call a component’s componentDidMount method?

A

Immediately after a component is mounted (first render) (inserted on DOM tree)

384
Q

Name three React.Component lifecycle methods.

A

constructor, componentDidMount, render

385
Q

How do you pass data to a child component?

A

passing a prop

386
Q

What does the acronym LIFO mean?

A

“Last in, First Out”

387
Q

What methods are available on a Stack data structure?

A

.peek(convenience), .pop, .push, .print(for debugging)

388
Q

What must you do to access the value at an arbitrary point in a stack (not just the “top”)?

A

You would have to pop off the top until you are at the point in the stack you wish to be at.

389
Q

What does the acronym FIFO mean?

A

“First In, First out”

390
Q

What methods are available on a Queue data structure?

A

.enqueue, .dequeue

391
Q

What must you do to access the value at an arbitrary point in a queue (not just the “front”)?

A

You’d have to dequeue until you get to the value that you wish to access

392
Q

How are linked lists different from an array?

A

Linked lists cannot be accessed randomly by an index. It is in sequential order.

393
Q

How would you access an arbitrary node in a linked list (not just the “head”)?

A

You would have to use the .next method in order to access the arbitrary node.

394
Q

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

A

The return value is the return of the inner function

395
Q

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

A

The return value is the return of the inner function

396
Q

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

A

When wrap is called, it will return the function inside that returns the value

397
Q

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

A

When it is defined

398
Q

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

A

Closures