Javascript / JQuery / OOP / JSON (junior) Flashcards

1
Q

What is a variable?

A

Where data can be stored!

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

Why are variables useful?

A

variable can be used to store and recall information through-out a program.

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

What two special characters can a variable begin with?

A

$ _

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

How do you declare a variable?

A

using a variable identifier

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

How do you assign a value to a variable?

A

= next to variable name

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

Are variables case sensitive?

A

yes

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

Which words cannot be used as variable names?

A

keywords (var, function, if) numbers..

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

What is a string?

A

Sub-series of characters that comes inside two ‘ or “

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

What is the string concatenation operator?

A

+

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

What is the difference when it comes to using single quotes or double quotes ( ‘ ‘ or “ “ )?

A

no difference in functionality

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

How do you escape quotation characters?

A

\ before the quote.

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

What is a number in JavaScript?

A

an integer

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

What is an arithmetic operator?

A

Mathematical function that takes two operands and performs a calculation on them.

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

Name four of the arithmetic operators?

A

add subtract

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

What is the order of execution?

A

PEMDAS

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

What is a boolean?

A

true / false

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

What is a comparison operator?

A

< = >

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

What is a comparison operator?

A

< = > == ===

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

What is a function?

A

Series of statements that are grouped together because they perform a specific task.

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

Why are functions useful?

A

you can reuse the function (rather than repeating the same set of statements).

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

How do you call a function?

A

function name followed by () with any argument inside.

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

What are the parts of a function definition?

A

function keyword, function name and code bloke inside curly braces.

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

What is the difference between a parameter and an argument?

A

methods are same as functions, except they’re created inside (and are part of) an object.

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

What is the difference between a parameter and an argument?

A

parameters are placeholders for values in function and arguments are the values when calling the function.

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

Why is it important to understand truthy and falsy values?

A

They allow decision making

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

Why is the typeof an object null?

A

it’s a bug!

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

What is the difference between null and undefined?

A

an undefined variable has no value, null has no specific value assigned to it but has a placeholder and act as an object ready to be assigned with a value.

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

What is the proper syntax for using the or operator?

A

|| double pipe

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

Why do you want to avoid using == for comparison?

A

== doesn’t check on type similarity!

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

Do all if statements require an else statement?

A

no

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

What is the primary use case for switches?

A

comparing any individual value against a range of other individual values.

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

Does the default case have to be at the bottom of the switch statement?

A

to get executed after checking for all possible cases

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

Does the default case have to be at the bottom of the switch statement?

A

no!

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

What is an object in JavaScript?

A

A set of variables and functions grouped together.

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

How do you create an object literal?

A

declaring a variable with a name for object, equal sign, curly braces and key/value for each property or method in between separated by comma

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

What is a property in relation to JavaScript objects?

A

A set of key and value.

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

When should you use bracket notation over dot notation with objects?

A

any time there’s illegal property name dot notation needs to be used to access the value

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

How do you remove a property from an object?

A

delete operator.

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

What is an array in JavaScript?

A

list of data

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

How do you create an array literal?

A

assigning data in brackets

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

What are the keys for the values inside an array?

A

index numbers.

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

Arrays have a property named length. Because arrays have a properties, what other data structure are they similar to?

A

objects

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

What are some good use cases for using objects inside arrays?

A

online shopping card with list of items and their properties (price, ..)

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

What is the primary advantage to storing your selected elements in a variable?

A

so they can be reused every time without a need to target them again

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

Why might you need JavaScript to modify the DOM after the page loads?

A

adjustments and updates based on user behavior

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

How can you better prepare when writing HTML for DOM manipulation in your JavaScript code?

A

setting better structure and placement for items that are going to be manipulated

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

What are the differences between innertext and textContent?

A

textContent gets the content of all elements, including and <style> elements. In contrast, innerText only shows “human-readable” elements.</style>

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

What datatype are the values you remove from a text input?

A

strings

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

Why is it so important to be able to dynamically update text?

A

to be able to updated the text content based on user interaction

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

What are some of the drawbacks of HTML Event Handler Attributes?

A

readibility, seperating html and JS codes

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

Why is the Window.event property to be avoided in new code?

A

window object gets rewrite/change with every change

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

What is the difference between the getElementById() method and the querySelector() method?

A

getElementById() is only for ids, querySelector() can be used to target any element

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

Who passes in the event object into the handleClick callback function?

A

JS

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

Does a callback function require a name?

A

no, but would be better to set name to describe the function and reusability

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

What is the purpose of a loop?

A

to rerun a code block while their condition is true

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

Why might there be different kinds of loops?

A

depending on the condition required to run a code block

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

What is the purpose of a conditional expression as it relates to loops?

A

to update the condition set every time loop runs the code block

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

Could a loop potentially go on forever?

A

yes!

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

Could a loop never start?

A

yes!

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

How do you target the value of a property in an object.

A

using bracket

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

When should you use a for in loop?

A

looping over an object

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

What is the difference between the parentNode and parentElement properties?

A

parentElement is the actual element, parentNode could be any item.

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

Why is it important to be able to traverse the DOM?

A

to access element based on where they’re located.

64
Q

What kind of information is useful to store in custom attributes?

A

to add information about the element and can be targeted and modified based on that information

65
Q

What are two ways to target elements on the DOM?

A

querySelector, getElementById

66
Q

What is another way to add a text node to an element other than using textContent.

A

innerText

67
Q

How do you create a HTML element using vanilla Javascript?

A

createElement

68
Q

Why is using loops and arrays for creating multiple dom elements preferable to creating them one at a time?

A

less code, prevent repeating the same code

69
Q

Why are arrays preferred over objects for the functionality referenced in question 1?

A

arrays are indexed and easier to go through

70
Q

Why is it important to be able to retrieve and use data from inputs?

A

.

71
Q

Why is it dangerous to assume you have the correct data when creating elements?

A

.

72
Q

What is jQuery?

A

a library/ JS file that can be added to web page to allow changing using css selectors easier

73
Q

What is the jQuery selector function?

A

$()

a function that allows selecting one or more element in the page

74
Q

What does the jQuery selector function return?

A

element

75
Q

Why would someone use jQuery over vanilla Javascript?

A

for selecting and modifying element easier

76
Q

What are some downsides from using jQuery over vanilla Javascript?

A

getting stuck using jquery and not being familliar enough with vanilla JS
jquery is on the way go out
it has a longer load time

77
Q

How do you get the text out of an HTML element?

A

.text()

78
Q

How do you get the value out of an HTML input field?

A

.val()

79
Q

What’s the difference between .text() and .html()?

A

.text() gets only text content and .html() get full element

80
Q

What does .on() do?

A

same as eventlistener

81
Q

What does .on() do?

A

set event listener, same as eventlistener

82
Q

What is event bubbling?

A

moving up containing element.

83
Q

What is the difference between event.target and event.currentTarget.

A

currentTarget is the where event was placed on and target is the immediate element

84
Q

What is the first argument the function setTimeout takes?

A

call back function

85
Q

If the second argument is not passed into the setTimeout function, what is the default value?

A

0

86
Q

What are some scenarios where setTimeout can be useful?

A

modal like newsletter

87
Q

What does the setInterval function return?

A

It returns an interval ID which uniquely identifies the interval, so you can remove it later by calling clearInterval().

88
Q

What argument does the clearInterval function take?

A

intervalID

89
Q

What are some scenarios where setInterval can be useful?

A

stopwatch, slideshow carousel

90
Q

What is the event loop?

A

moving events from queue to stack

91
Q

What does the term blocking mean?

A

on long action that blocks all other actions to run while fully executed

92
Q

What is the call stack?

A

set of actions running in order of “lifo” “last in last out”

93
Q

Which elements in a website are useful to create dynamically?

A

search results

94
Q

Why should you not create all elements dynamically?

A

not necessary, would be easier to have placeholder “container” and buttons pre-made and ready to target.

95
Q

Why do we need a single source of truth?

A

so we can easily access and modify the data. to make sure the data set is always updated and dom is updating based on the data model.

96
Q

Why would I create a function to generate my DOM Element instead of just writing my code in the global scope?

A

.

97
Q

What is a method?

A

functions inside objects

98
Q

What does a method do?

A

runs a function based of instruction inside the object

99
Q

What is this?

A

refers to the state that the code is being excuted in

100
Q

What does bind do?

A

the method that binds a specific value to “this” (where the codes get executed.

101
Q

What is the difference between a function and an object literal?

A

functions are callable objects, they have (apply, bind, call)

102
Q

What is Prototypal Inheritance?

A

adding features (properties) from one object to another

103
Q

What is the Prototypal Chain?

A

going up the latter of properties inherited from other objects

104
Q

In the custom objects we created, I noticed that our prototype object has another __proto__ property, where did that come from?

A

window (global) object

105
Q

Why does JavaScript have Prototypal Inheritance?

A

to enable easier object creation, mainly to save memory

106
Q

What does the new keyword do?

A

it creates an instance of an object

107
Q

I could’ve added a method to the constructor function by assigning a method to a property on the this object. Why do we have to add it to the prototype property?

A

memory efficiency. the properties get inherited and doesn’t need to be on the instance object itself!

108
Q

Since classes are technically functions as well. Can you name a difference between classes and functions?

A

function declarations and class declarations is that function declarations are hoisted and class declarations are not.

109
Q

What is the first thing that happens in a class when it is instantiated with the new keyword?

A

it calls the constructor function of the object

110
Q

What is the benefit of instantiating Classes within other classes?

A

child objects can inherit the data and code features of their parent class, so you can reuse functionality common to all the object types rather than having to duplicate it.

111
Q

Why are parent - child relationships important in OOP?

A

using the data and features of parent class/object

112
Q

What is the basic idea of OOP?

A

pairing data with functionality

113
Q

Why did you have to bind this for the feedChild method in the Parent class?

A

wouldn’t be able to get the data from other object

114
Q

Why is it important to assign callback methods to properties in the constructor?

A

so they dont get destroyed and be able to use them once passed the constructor

115
Q

Why did the Maker class require all of the Parent class info?

A

to have the values to pass to.

116
Q

Why did you have to bind this for the replenishFood method.

A

so it can be called from another object

117
Q

What decides the order in which JS files must be loaded?

A

whichever tools that needs to be called has to be placed and defined first

118
Q

What is JSON?

A

a text-based data format following the JS object syntax

119
Q

What are serialization and deserialization and why are they useful?

A

The process of turning an object in memory into a string so it can be modified or sent over the network or from a string to an object so it can be used

120
Q

How do you deserialize a JSON string using JavaScript?

A

JSON.parse()

121
Q

What is a client?

A

what send a request to receive response

122
Q

What is a server?

A

what would run a service to serve web page, files ect ..

123
Q

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

A

GET

124
Q

What are the formats of HTTP Requests and Responses?

A

Start Line, Headers, Body

125
Q

How does ajax work?

A

by sending XHR underneath

126
Q

Why did we need the jQuery CDN?

A

so the library code can be used

127
Q

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

A

by using method property

128
Q

Why might you need to build elements dynamically with data from an AJAX request?

A

so it can be created based on the amount (length) of the data getting back

129
Q

Should you use named functions or anonymous functions for success and error handlers?

A

named functions help with readability and better organization (clean code)

130
Q

Variables defined with the var keyword are function scoped. const and let are _____ scoped.

A

block-scoped

131
Q

Name some characteristics of a variable declared using const

A

immutable, must always initialize immediately

132
Q

Name some characteristics of a variable declared using let

A

they are mutable

133
Q

What does block scope mean?

A

the code block between curly braces

134
Q

In the file we can push a new value to an array defined using the const variable. How does that work?

A

the reference value (property) of the const variable can be updated

135
Q

Name some things that var can do that const and let can’t.

A

var can be hoisted on load

136
Q

If var can be used virtually anywhere, why would we switch?

A

using let and const helps to create variables for specific blocks and prevent c

137
Q

What is the syntax in writing a template literal?

A

${}

138
Q

What is string interpolation?

A

it converts a dynamically computed value into a string and inserted to the string returned by the literal.

139
Q

When was destructuring introduced?

A

ES6 2015

140
Q

Why could the running commas technique of destructuring an array be a bad idea?

A

keeping the count of the indexes

141
Q

How can you easily tell the difference between destructuring and creating array/object literals.

A

destructuring takes place on left side

142
Q

How does an ES6 arrow function differ from an ES5 function?

A

no function keyword, less verbose and dont require binding, no personal block scope

143
Q

When an arrow function’s code block is left without curly braces, what (if anything) changes in its functionality?

A

return the result of expression without return keyword

144
Q

In what situations would you possibly use an arrow function?

A

.

145
Q

In what situations would you not want to use an arrow function?

A

for methods

146
Q

What is Array.prototype.filter useful for?

A

filtering out items based on the argument passed into it

147
Q

What is Array.prototype.map useful for?

A

to return the result of a function on each input value

148
Q

What is Array.prototype.reduce useful for?

A

to get the result of ta function based on input value

149
Q

What are the three states a Promise can be in?

A

pending, fulfilled, rejected

150
Q

How do you handle the fulfillment of a Promise?

A

using .then() passing the value received

151
Q

How do you handle the rejection of a Promise?

A

by using .catch() passing error received as argument

152
Q

What does fetch() return?

A

a promise containing a response object

153
Q

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

A

GET

154
Q

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

A

pass method as second argument of fetch

155
Q

When does React call a component’s componentDidMount method?

A

immediately after a component is mounted (inserted into the tree)

156
Q

Name three React.Component lifecycle methods.

A

constructor()
render()
componentDidMount()

157
Q

How do you pass data to a child component?

A

.