HTML Flashcards

1
Q

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

A

Within the 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

Within the body element

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

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

A

Within the html element

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

What is the purpose of a ! DOCTYPE declaration?

A

To inform the web browser about what version of html the page is written in

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

Give five examples of HTML element tags.

A
div
h1
p
img
article
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

To add details/extra info to elements

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
& = & a m p ;
< = & l t ;
> = & g t ;
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

It creates a line break.

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

It stays within the same line if possible and only takes as much space as needed.

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

width: 100%
height: auto

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

width: auto
height: auto

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

An ordered list is numbered.

An un ordered list has bullet points.

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

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

A

Block 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 (tag for anchor element)
<a href=""></a>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an absolute URL?

A

Complete web address starting with domain name (must include https://)

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

What is a relative URL?

A

Shorthand address linking parts/pages within the same website (omits domain name)

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

../filename

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

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

A

directory/filename

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

../../filename

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

its own filename
or
#id within same page

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

Form element sets boundary /enclosure for form control elements

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

Give three examples of type attributes for HTML elements.

A

text
password
radio
checkbox

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

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

A

Inline element

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

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

A

.class {

}

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

In CSS, how do you select elements by their type?

A

element {

}

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

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

A
#id {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

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

A

hex code
rgb/rgba
color name
hsl/hsla

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

What CSS properties make up the box model?

A

Border
Margin
Padding

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

What is a pseudo-class?

A

A keyword/class added to a selector after : to specify a special state of the selected element to which the rule set will be applied.

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

What are CSS pseudo-classes useful for?

A

Creating an interactive website

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

Name at least two units of type size in CSS.

A

px
em
rem

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

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

A

Row (from left to right)

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

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

A

Nowrap (same line)

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

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

A

Because they are block elements.

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

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

A

Row

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

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

A

No change

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

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

A

It changes location in relation to normal location of static position.

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

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

A

The element is removed from the document flow entirely.

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

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

A

It changes location in relation to its containing element with disregard to other sibling elements.

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

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

A

Set the containing block to

position: relative; or absolute; (non-static)

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

What are the four box offset properties?

A

top
bottom
left
right

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

What is the purpose of variables?

A

To store data, which can be accessed later and inserted in functions .

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

How do you declare a variable?

A

Use ‘var’, ‘let’, or ‘const’ + variable name

Different scoping

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

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

A

= value

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

What characters are allowed in variable names?

A

Dollar sign, underscore, numbers, and letters. (Cannot start with a number.)

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

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

A

Names in different cases are considered as different variables.

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

What is the purpose of a string?

A

To assign text-content data / series of characters; naming and assigning significance

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

What is the purpose of a number?

A

To assign a number-type value; calculations

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

What is the purpose of a boolean?

A

To assign a value of true/false. Its purpose is to make a decision.

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

What does the = operator mean in JavaScript?

A

Value is assigned to

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

How do you update the value of a variable?

A

Reassign the variable / update the value of the variable by using an equal sign without declaration keywords such as ‘var’

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

What is the difference between null and undefined?

A

Null is an object type data. (Must be assigned. Intentional.)
Undefined is an undefined type data. (When a variable is declared but no value is assigned. Usually by mistake.)

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

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

A

To clarify what the values are for, since console.log only shows values unless labeled.

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

Give five examples of JavaScript primitives.

A
String
Number
Boolean
Undefined
Null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

What data type is returned by an arithmetic operation?

A

Number which is the result of a calculation

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

What is string concatenation?

A

To combine multiple strings.

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

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

A

It combines strings.

It also adds numbers.

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

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

A

Boolean

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

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

A

x += y returns x = x + y

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

What are objects used for?

A

To create a collection of things

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

What are object properties?

A

Individual pieces of data stored within an object

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

Describe object literal notation.

A

Variable key = {
property: value;
}

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

How do you remove a property from an object?

A

Use the operator delete followed by a dot notation

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

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

A

dot notation
or
bracket notation

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

What are arrays used for?

A

To list out multiple values, usually similar data

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

Describe array literal notation.

A

Square brackets:

variable = [ ] ;

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

How are arrays different from “plain” objects?

A

Numbered index
To add a value to an array:
arrayName.push(objectName)

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

What is the length property of an array?

A

arrayName.length

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

How do you calculate the last index of an array?

A

arrayName.length - 1

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

What is a function in JavaScript?

A

A special type of object that can be called. Its function is to re-use the codes.

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

Describe the parts of a function definition.

A
Function keyword,
Function name (optional),
Parameter (can be empty),
Code block,
Return statement (optional).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
78
Q

Describe the parts of a function call.

A

Function name,

Parenthesis containing optional arguments.

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

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

A

Call runs the code, using actual values.

Definition defines the code, using a code block.

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

What is the difference between a parameter and an argument?

A

Function parameters are the names listed in the function’s definition. Function arguments are the real values passed to the function.

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

Why are function parameters useful?

A

To push additional data into the same function

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

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

A

(1) Produces a value where the function is called.

(2) Stops and exits the function.

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

Why do we log things to the console?

A

To inspect codes / For debugging purposes.

It is a method for developers to write code to inconspicuously inform the developers what the code is doing.

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

What is a method?

A

Function stored within a property of an object

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

How is a method different from any other function?

A

It requires an object

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

How do you remove the last element from an array?

A

object.pop()

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

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

A

Math.floor()

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

How do you generate a random number?

A

Math.floor(Math.random() * range)

Ex:
function getRandomNumberInRange(start, end) {
var randomNum = Math.floor(Math.random() * (end-start) + 1 ) + start;
return randomNum;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

How do you delete an element from an array?

A

array.splice(index)

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

How do you append an element to an array?

A

To add to end of array:
array.push()
To add to start of array:
array.unshift()

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

How do you break a string up into an array?

A

array.split(‘breakpoint’)

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

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

A

No, strings are immutable.

You can check by console.log().

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

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

A

100

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

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

A

Not all the time.

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

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

A

100

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

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

A

MDN

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

Give 6 examples of comparison operators.

A
===
>
<
>=
<=
!===
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
98
Q

What data type do comparison expressions evaluate to?

A

Boolean

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

What is the purpose of an if statement?

A

To execute a function depending on a condition

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

Is else required in order to use an if statement?

A

No, it’s optional

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

Describe the syntax (structure) of an if statement.

A
if (condition) {
function
};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
102
Q

What are the three logical operators?

A

|| (OR), && (AND), ! (NOT).

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

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

A

Use a logical operator and put parenthesis around each condition.

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

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

A

To see if the code is permitted to run.

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

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

A

Single time that code block within declaration runs.

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

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

A

Before each iteration

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

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

A

Before anything

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

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

A

Right after every time code is run.

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

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

A

Break

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

What does the ++ increment operator do?

A

Add 1

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

How do you iterate through the keys of an object?

A

For…In Loop

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

What are the four components of “the Cascade”.

A

Source Order
Inheritance
Specificity
!Important Rule

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

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

A

The order CSS rules are written in a stylesheet. The styling provided for an element last in your stylesheet is the styling that will ultimately take effect.

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

Inheritance

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

Why is using !important considered bad practice?

A

It hinders debugging by breaking the natural cascading in CSS stylesheet.

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

Why do we log things to the console?

A

To check the values of variables.

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

What is a “model”?

A

Representation or Re-creation of an actual thing.

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

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

A

html document

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

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

A

JavaScript object

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

What is a DOM Tree?

A

The Document Object Model is a cross-platform and language-independent interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with a logical tree.

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

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

A

document. getElementByID();

document. querySelector();

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

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

A

document.querySelectorAll();

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

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

A

So that we can re-use the variable to locate the desired object.

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

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

A

When you place your JavaScript at the bottom of your HTML body, it gives the HTML time to load before any of the JavaScript loads, which can prevent errors, and speed up website response time.

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

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

A
CSS selector(s).
It returns the first element with matching selector(s).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
128
Q

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

A
CSS selector(s).
It returns all elements with matching selector(s).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
129
Q

Why do we log things to the console?

A

To check functions are running without errors. To check values.

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

What is the purpose of events and event handling?

A

To respond to certain events, for organic interactions and dynamic features.

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

What is a callback function?

A

Function getting passed around as a value to other places.

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

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

A

Event object

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

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

A

console.dir(event.target);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
135
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 the element where the event occurs.
console.log & console.dir(event.target);
MDN;

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

What is the difference between these two snippets of code?

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

A

If there is a parenthesis, function is being called when page loads, instead of when the event happens.

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

What is the className property of element objects?

A

Used either to retrieve current value of, or assign a new value (update) of, the class name of an element.

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

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

A

element.querySelector( css selector).className = ‘newName’

139
Q

What is the textContent property of element objects?

A

Grabs just the text of an element, without grabbing styling details.

140
Q

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

A

element.querySelector( css selector).textContent = ‘newText’

141
Q

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

A

No, not always necessary.

142
Q

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

A

More complicated.

143
Q

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

A

It saves so much time and energy of both the user and the computer.

144
Q

What does the transform property do?

A

To alter an object spatially.

To modify the coordinate space of the CSS.

145
Q

Give four examples of CSS transform functions.

A

Rotate
Scale
Skew
Translate

146
Q

The transition property is shorthand for which four CSS properties?

A

transition-property
transition-duration
transition-timing-function
transition-delay

147
Q

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

A

Focus

148
Q

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

A

Blur

149
Q

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

A

Input

150
Q

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

A

Submit

151
Q

What does the event.preventDefault() method do?

A

Tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be.

152
Q

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

A

Page reloads.

153
Q

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

A

.elements

154
Q

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

A

.value

155
Q

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

A

It’s more difficult to troubleshoot and takes more time.

156
Q

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

A

You can constantly check your codes as writing them.

157
Q

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

A

parent.appendChild(child)

158
Q

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

A

‘Name’, value

of attribute

159
Q

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

A

variable = document.createElement
query parent element
parent.appendChild(child)

160
Q

What is the textContent property of an element object for?

A

To grab textContent so that you can update it.

161
Q

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

A

.setAttribute

.className

162
Q

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

A

You can use the same set of data repeatedly to create different projects.

163
Q

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

A

min-width

max-width

164
Q

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

A

Viewport meta tag

165
Q

What is the event.target?

A

Element receiving the event

166
Q

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

A

Due to bubbling event flow

167
Q

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

A

element.tagName

168
Q

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

A

Argument: CSS selector
Return: element that is the closest ancestor with matching selector

169
Q

How can you remove an element from the DOM?

A

element.remove()

170
Q

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

A

Add event listener to the closest parent containing those DOM elements.

171
Q

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

A

It completely hides the element.

172
Q

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

A

Argument: string of selector
Return: boolean value

173
Q

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

A

element.getAttribute(‘attributename’)

174
Q

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

A

After declaring a new variable,
After looping,
After updating a value, etc.

175
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

Since $tabList is a node list, you would have to do ‘addEventListener’ to each of the individual nodes inside node list.

176
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

You have to write codes for every possible situation. (for each index)

177
Q

What is a breakpoint in responsive Web design?

A

What is a breakpoint in responsive design? In responsive design, a breakpoint is 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.

178
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

Width of an element can be automatically calculated instead of being fixed at a certain value. This maintains proportions and thus makes the layout more responsive and aesthetic.

179
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

It’s just following cascading rules.

(Same specificity, different source order).

180
Q

What is JSON?

A

JSON is a format that encodes objects in a string.

It is commonly used for transmitting data in web applications.

181
Q

What are serialization and deserialization?

A

Simply speaking Serialization is a process of converting an Object into stream of bytes so that it can be transferred over a network or stored in a persistent storage.

Deserialization is the exact opposite - Fetch a stream of bytes from network or persistence storage and convert it back to the Object with the same state.

The thing to understand is how those stream of bytes are interpreted or manipulated so that we get the exact same Object/ same state. There are various ways to achieve that. Some of them are -

XML: Convert Object to XML, transfer it over a network or store it in a file/db. Retrieve it and convert it back to the object with same state. In Java we use JAXB(Java architecture for XML binding) library.(From java 6 it comes bundled with JDK).
JSON: Same can be done by converting the Object to JSON (JavaScript Object notation). Again there is GSON library that can be used for this.
Or we can use the Serialization that is provided by the OOP language itself. For example, in Java you can serialize an Object my making it implement Serializable interface and writing to Object Stream.

182
Q

Why are serialization and deserialization useful?

A

Transfer of data over a network

183
Q

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

A

JSON.stringfy()

184
Q

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

A

JSON.parse()

185
Q

How to you store data in localStorage?

A

localStorage.setIte(‘keyName’, ‘keyValue’);

186
Q

How to you retrieve data from localStorage?

A

localStorage.getItem(‘keyName’);

187
Q

What data type can localStorage save in the browser?

A

String. The keys and the values stored with localStorage are always in the UTF-16 DOMString format.

188
Q

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

A

When the window is about to be unloaded.

189
Q

What is a method?

A

A method is a function which is a property of an object.

190
Q

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

A

Using var, const, let

191
Q

Describe method definition syntax (structure).

A
var objectName = {
methodName: function(parameter) {
function block
}
};
192
Q

Describe method call syntax (structure).

A

objectName.methodName(argument);

193
Q

How is a method different from any other function?

A

It only works on specific object(s).

194
Q

What is the defining characteristic of Object-Oriented Programming?

A

Objects can contain both data (as properties) and behavior (as methods).

195
Q

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

A

Abstraction
Encapsulation
Inheritance
Polymorphism

196
Q

What is “abstraction”?

A

Reducing a complex idea/function to a simplified interaction mechanism.

197
Q

What does API stand for?

A

Application Programming Interface. It is a type of software interface, offering a service to other pieces of software.

198
Q

What is the purpose of an API?

A

The purpose of every software API is to give programmers a way to interact with a system in a simplified, consistent fashion: aka, an abstraction.

199
Q

What is this in JavaScript?

A

this is an implicit parameter of all JavaScript functions.

200
Q

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

A

Parameters are not explicitly spelled out in a function definition’s parameter list.

201
Q

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

A

The value of this is determined at the call time of the function.

202
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

Nothing.
It doesn’t have a value yet, because the greet method’s function () has not been called.
When it is called, this will refer to the the object character.

203
Q

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

character.greet();

A

The result will be a console log of the message of the concatenated string ‘It’s-a-me, Mario!’

Reason: It is calling a function.

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

Undefined.

Reason: When greet method’s function is not called, here this refers to the window when the function hello is called. Window does not have firstName property.

205
Q

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

A

By looking at what kind of object comes before it within the definition code block.
This is only a value when a function is being invoked. When a function is being invoked, this refers to the object to the left of the dot.

206
Q

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

A

By looking at what kind of object comes before it within the definition code block.
This is only a value when a function is being invoked. When a function is being invoked, this refers to the object to the left of the dot.

207
Q

What kind of inheritance does the JavaScript programming language use?

A

Prototype-based (or Prototypal) Inheritance, which means that JavaScript objects give certain behaviors (methods) or data (properties) to other objects.

208
Q

What is a prototype in JavaScript?

A

An object that contains properties and (predominantly) methods that can be used by other objects.

209
Q

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

A

By defining a prototype, then:

Object.setPrototypeOf(object, prototypeObject);

210
Q

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

A

Its prototype object.

211
Q

What does the new operator do?

A

It creates an instance of a constructor.

Steps:

  1. Creates an empty object
  2. Adds a property to the new object (__proto__) that links to the constructor function’s prototype object
  3. Binds the newly created object instance as the this context
  4. Function runs, then Returns this if the function doesn’t return an object.
212
Q

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

A

prototype

213
Q

What does the instance of operator do?

A

Returns a boolean value of whether the variable represents an instance of the constructor

214
Q

What is a “callback” function?

A

A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.

215
Q

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

A

setTimeout();

216
Q

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

A

setInterval();

217
Q

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

A

Zero.

218
Q

What do setTimeout() and setInterval() return?

A

Return of setTimeout():
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.

Return of setInterval():
undefined;

219
Q

What is a client?

A

Service requesters

220
Q

What is a server?

A

Service providers (always listening)

221
Q

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

A

GET

222
Q

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

A

Method
Target
HTTP Version

223
Q

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

A

Protocal Version
Status Code
Status Text

224
Q

What are HTTP headers?

A

Additional meta data;

Easily accessible for user

225
Q

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

A

MDN

226
Q

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

A

No

227
Q

What is AJAX?

A

a programming practice of building complex, dynamic webpages using a technology known as XMLHttpRequest.

228
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript And XML,

229
Q

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

A

XMLHttpRequest() object;

230
Q

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

A

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

231
Q

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

A

load event

232
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();

233
Q

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

A

Whatever sits inside a curly brace pair {}
function body,
loop code blocks,
conditional code blocks

234
Q

What does block scope mean?

A

Existing only within the code block in between curly braces.

235
Q

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

A

block scope

236
Q

What is the difference between let and const?

A

let: variable’s value can be re-assigned.
const: variable’s value cannot be re-assigned.

237
Q

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

A

Because .push() changes the array, but it doesn’t re-assign name-binding. We’re not assigning a new value to the variable.

238
Q

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

A

Stick with const until you can’t.

239
Q

What is the syntax for writing a template literal?

A

backticks ``

for value of variables: ${}

240
Q

What is “string interpolation”?

A

The substitutions allow you to embed variables and expressions in a string. The JavaScript engine will automatically replace these variables and expressions with their values. This feature is known as string interpolation.

241
Q

What is destructuring, conceptually?

A

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

242
Q

What is the syntax for Object destructuring?

A

const {property: variable, … } = object

243
Q

What is the syntax for Array destructuring?

A

const [array[0]: variable, … ] = array

244
Q

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

A

{} or []

245
Q

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

A

Must be an expression.

It returns the expression.

246
Q

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

A

Inherits this value from its parent (closest ancestor) code block.

247
Q

Use for command: cat

ls
pwd
echo
touch
mkdir
mv
rm
cp
A

print or combine contents of a file

248
Q

Use for command: ls

A

list

249
Q

Use for command: man

A

show manual

250
Q

Use for command: pwd

A

print working directory

251
Q

Use for command: echo

A

Similar to console.log

252
Q

Use for command: touch

A

Create a file / Time stamper?

253
Q

Use for command: mkdir

A

Make directory

254
Q

Use for command: mv

A

Rename a directory

When you’re moving something, you’re also renaming it

255
Q

Use for command: rm

A

Remove a file/directory

256
Q

Use for command: cp

A

Copy a file/directory

257
Q

What are the three virtues of a great programmer?

A

laziness,
impatience,
hubris

258
Q

What is Node.js?

A

As an asynchronous event-driven JavaScript runtime

259
Q

What can Node.js be used for?

A

build scalable network applications.

260
Q

What is a REPL?

A

A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise.

261
Q

When was Node.js created?

A

May 27, 2009

262
Q

What back end languages have you heard of?

A
PHP,
Ruby,
Python,
JavaScript,
Perl,
TypeScript,
Elixir,
Lisp,
Clojure,
SQL,
Java,
Kotlin,
Scala,
Haskell,
Go,
C,
C++,
VBA,
C#,
F#,
Fortran,
Pascal,
Julia,
Rust,
Objective-C,
Swift
263
Q

What is a computer process?

A

In computing, a process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity.

264
Q

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

A

Hundreds

265
Q

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

A

Because full stack web development involves multiples processes

266
Q

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

A

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

267
Q

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

A

by using the argument process.

268
Q

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

A

Array of strings

269
Q

What is a JavaScript module?

A

In JavaScript, modules are files.

270
Q

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

A

filename, dirname, module, export, require

271
Q

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

A

process

272
Q

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

A

To export functionality of a Node.js module into another Node.js module.

273
Q

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

A
In new module do: const add = require('./add') (relative file path)
after doing: module.property = function. in original module.
274
Q

What is the JavaScript Event Loop?

A

The call stack is a LIFO queue (Last In, First Out). The event loop continuously checks the call stack to see if there’s any function that needs to run.

275
Q

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

A

A blocking assignment takes affect immediately it is processed. A nonblocking assignment takes place at the end of processing the current “time delta”.
Blocking is in call stack.

276
Q

What is a directory?

A

A reference to the location of files or other directories

277
Q

What is a relative file path?

A

A relative path refers to a location that is relative to a current directory.

278
Q

What is an absolute file path?

A

An absolute path always contains the root element and the complete directory list required to locate the file.

279
Q

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

A

fs module

280
Q

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

A

fs.writeFile

281
Q

Are file operations using the fs module synchronous or asynchronous?

A

both synchronous and asynchronous
Sync = blocking
Asynchronous is almost always better

282
Q

What is a package?

A

a directory with one or more files in it that also has a file called package.json with some metadata about this package

283
Q

How do you add express to your package dependencies?

A

npm install

284
Q

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

A

app.listen()

285
Q

Difference between internet vs. web?

A
Internet = Global network of computers
Web = messaging format called HTTP
286
Q

How do you mount a middleware with an Express application?

A

app.use() method

287
Q

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

A

req, res objects

288
Q

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

A

application/json

289
Q

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

A

It parses incoming requests with JSON payloads/data.

290
Q

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

A

To get a desired action from a request

291
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS). It is often cited as the most advanced open source database of its kind and is well-liked by the developer community for its robust feature set, standards compliance, and reliability.
Other relational databases include MySQL (also free), SQL Server by Microsoft, and Oracle by Oracle Corporation.

292
Q

What are some advantages of learning a relational database?

A

A quality of many relational databases is that they support good guarantees about data integrity. They can store and modify data in a way that makes data corruption as unlikely as possible. This means that developers can set up their database to reject “bad” data and not worry about data being “half written”. For more information, read about ACID.

293
Q

What is one way to see if PostgreSQL is running?

A

top

294
Q

What is a database schema?

A

A collection of tables is called a schema. A schema defines how the data in a relational database should be organized.

295
Q

What is a table?

A

A table is a list of rows, showing relations of data

296
Q

What is a row?

A

Each row has the same set of attributes.

297
Q

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

A

Language that allows for interacting with relational databases. A way of retrieving, creating, and manipulating data in relational databases.
It is declarative instead of imperative, meaning it comes up with a way to process requested function.

298
Q

How do you retrieve specific columns from a database table?

A

select “columnName”

299
Q

How do you filter rows based on some specific criteria?

A

where “columnName” = condition true/false

300
Q

What are the benefits of formatting your SQL?

A

Readability

301
Q

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

A

=, !=, >, =, <=,

anything true or false

302
Q

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

A

limit #

303
Q

How do you retrieve all columns from a database table?

A

select *

304
Q

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

A

order by “columnName”

305
Q

How do you add a row to a SQL table?

A

insert into “tableName” (“columnName”)

values (“columnValue”);

306
Q

What is a tuple?

A

a list of values inside parenthesis

307
Q

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

A

multiple tupules, comma separated.

308
Q

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

A

returning *;
or
returning “columnName”

309
Q

How do you update rows in a database table?

A

update “tableName”
set “columnName” = ‘columnValue’
where “columnName” = ‘columnValue’;

310
Q

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

A

Otherwise, you are updating all rows.

311
Q

How do you delete rows from a database table?

A

delete from “tableName”

where “columnName” = ‘columnValue’;

312
Q

How do you accidentally delete all rows from a table?

A

By omitting where clause

313
Q

What is a foreign key?

A

a shared key value that links different tables together

314
Q

How do you join two SQL tables?

A

join “tableName” using (“columnName”)

315
Q

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

A

as “pseudonym”

316
Q

What are some examples of aggregate functions?

A
count()
sum()
min()
max()
avg()
every()
317
Q

What is the purpose of a group by clause?

A

Combining data by groups/categories and perform aggregate function across the groups instead of generating just one result and combining all data

318
Q

What are the three states a Promise can be in?

A

pending, fulfilled, rejected

319
Q

How do you handle the fulfillment of a Promise?

A

then method

320
Q

How do you handle the rejection of a Promise?

A

catch method

321
Q

What is “syntactic sugar”?

A

Syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express.

322
Q

What is the typeof an ES6 class?

A

function

323
Q

Describe ES6 class syntax.

A
class Person {
    constructor(name) {
        this.name = name;
    }
    getName() {
        return this.name;
    }
}

let john = new Person(“John Doe”);

324
Q

What is “refactoring”?

A

Restructuring codes without changing functionality

325
Q

tick(), getTime(), reset() -> Are they commands or queries?

A

tick() is a command, and getTime() is a query.
A command changes values while a query doesn’t.
When coding, trying to use queries when possible. Use commands only when necessary and separate them from queries.

326
Q

How are ES Modules different from CommonJS modules?

A
CommonJS require() and module.exports statements, whereas
ES6 modules use import and export default statements.

CommonJS module is executed at require command.
ES6 modules is not executed at import command but generates a reference to the loaded module.
ES6 is official.
——–

  1. CommonJs exports a copy of variables, and ES6 Module exports the binding of variables.
  2. CommonJs exports a single value export, and ES6 Module can export multiple values.
  3. CommonJs is a dynamic syntax (runtime) that can be written in judgment, while ES6 Module static syntax (compile time) can only be written in the top level
327
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules.

328
Q

What is React?

A

React is a JavaScript library for creating user interfaces.

The react package contains only the functionality necessary to define React components. It is typically used together with a React renderer like react-dom for the web, or react-native for the native environments.

329
Q

What is a React element?

A

object

330
Q

How do you mount a React element to the DOM?

A

ReactDOM.render( )

331
Q

What is JSX?

A

syntax extension

332
Q

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

A

So that the compiled elements can call its React.crateElemenet method

333
Q

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

A

install webpack and babel as devDependencies and do npm run build for webpack

334
Q

How do you define a function component in React?

A
function functionName {
return (
reactElement
)
}

Function component MUST BE capitalized.

335
Q

How do you mount a component to the DOM?

A

ReactDOM.render(
,
div
);

336
Q

What are props in React?

A

attributes to React elements

337
Q

How do you pass props to a component?

A
338
Q

How do you write JavaScript expressions in JSX?

A

curly braces {}

339
Q

How do you create “class” component in React?

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

How do you access props in a class component?

A

this.props.text

Must use this

341
Q

What is the purpose of state in React?

A

State is a plain JavaScript object used by React to represent an information about the component’s current situation.
Just like data model.

342
Q

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

A

As a prop to a React element

343
Q

What are controlled components?

A

A controlled component is a component that renders form elements and controls them by keeping the form data in the component’s state. In a controlled component, the form element’s data is handled by the React component (not DOM) and kept in the component’s state.

344
Q

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

A

value

onChange