JS Flashcards

1
Q

Why are variables useful?

A

Save data and return to it

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

How do you declare a variable?

A

var

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

How do you assign a value to a variable?

A

the assignment operator (=)

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

Are variables case sensitive?

A

yes

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

Which words cannot be used as variable names?

A

keywords, cant start with numbers

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

What is a string?

A

data type of text

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

What is the string concatenation operator?

A

+

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

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

A

nothing

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

How do you escape quotation characters?

A

/”

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

What is type coercion?

A

a different data type becoming a string only because it was concatenated with a string

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

What is a number in JavaScript?

A

a number

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

What is an arithmetic operator?

A

+, -, *, etc.

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

Name four of the arithmetic operators?

A

+, -, *,/

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

a data type of true and false values

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

What is a comparison operator?

A

an operator that compares variables and returns a boolean value accordingly

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

What is the difference between undefined and null?

A

undefined is an empty variable argument while null is an argument with a specified value of emptiness. A human must specify a null value.

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

What is a function?

A

Functions group statements together to perform a task.

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

Why are functions useful?

A

Functions enable the reuse of these specific groupings of statements in the future as opposed to recreating matching code for different arguments.

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

How do you call a function?

A

functionName(arguments)

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 Name(parameters) {
return code  block
}
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

a parameter is the required information needed in order to call a function while an argument are the actual values being passed to the function upon its calling

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

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

A

Nope, but should be

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is an object in JavaScript?
its a reference data type that contains properties and methods
26
How do you create an object literal?
var name = {};
27
When should you use bracket notation over dot notation with objects?
when you only want to target properties and not methods
28
How do you remove a property from an object?
delete object
29
What is an array in JavaScript?
objects are storage area, arrays are for lists to loop through usually
30
How do you create an array literal?
var name = []
31
What are the keys for the values inside an array?
indexed from 0
32
Arrays have a property named length. Because arrays have a properties, what other data structure are they similar to?
objects
33
Why is the Window.event property to be avoided in new code?
It changes too often so you cannot be certain you're speaking to the correct event
34
What is the difference between the getElementById() method and the querySelector() method?
getElementById()
35
Who passes in the event object into the handleClick callback function?
JavaScript
36
Does a callback function require a name?
No, but you should
37
What is the purpose of a loop?
Repeat functionality that differs slightly in input
38
Why might there be different kinds of loops?
Whether you know the exact number of iterations for the loop or not determines between a for and while loop, respectively.
39
What is the purpose of a conditional expression as it relates to loops?
Whether or not to continue iterating
40
Could a loop potentially go on forever?
Yes
41
Could a loop never start?
Yes
42
How does a for loop differ from a while loop?
for loop you know the length to loop over
43
Which pieces of information provided in the parentheses for a for loop are mandatory?
technically none
44
What potential use cases are there for for loops?
anything array
45
What is a for in loop?
a loop over the properties of an object
46
How do you target the value of a property in an object.
brackets[]
47
When should you use a for in loop?
when you want to loop over an object
48
What is the difference between the parentNode and parentElement properties?
parentElement is always an element
49
Why is it important to be able to traverse the DOM?
Select what element youre selecting based on the elements around it instead of re-searching through the entire DOM.
50
How would you alter the game to make the choice from 1 - 500?
Math.floor(Math.random() *500)+1
51
What are the disadvantages of inline styling via JavaScript?
Inline styling is very strong and hard to override. Also bad to mix languages?
52
Why is it dangerous to assume you have the correct data when creating elements?
You might not have the create elements!
53
What is the first argument the function setTimeout takes?
A function definition
54
If the second argument is not passed into the setTimeout function, what is the default value?
0ms
55
What are some scenarios where setTimeout can be useful?
is the user still there?
56
What does the setInterval function return?
the ID
57
What argument does the clearInterval function take?
the ID to clear that set interval
58
What are some scenarios where setInterval can be useful?
a stopwatch, a timed carousel
59
What is the event loop?
it watches the task cue and call stack to shift elements between the two
60
Why do we need a single source of truth?
Make sure there are no inconsistencies between DOM and data model
61
What is a method?
A function in an object. Object.method()
62
What does a method do?
Anything a function can do
63
What is Prototypal Inheritance?
When elements inherit properties from other elements in JS
64
What is the Prototypal Chain?
When an element cannot find
65
In the custom objects we created, I noticed that our prototype object has another __proto__ property, where did that come from?
anytime an object is created with curly braces, the __proto__ is inherited.
66
Why does JavaScript have Prototypal Inheritance?
so we can save memory by reusing properties
67
Why are parent - child relationships important in OOP?
saving classes onto classes allows them to communicate
68
What is the basic idea of OOP?
Avoid spaghetti code. | Super scalable
69
When was destructuring introduced?
es6 (es2015)
70
Why could the running commas technique of destructuring an array be a bad idea?
Leaves reliance on user correctly counting commas. More room for error.
71
How can you easily tell the difference between destructuring and creating array/object literals.
Destructuring places the brackets or braces on the left of the assignment operator while assigning is on the right.
72
How does an ES6 arrow function differ from an ES5 function?
``` () => {} Syntax as opposed to function name() {} ```
73
When an arrow function's code block is left without curly braces, what (if anything) changes in its functionality?
implicit return
74
In what situations would you possibly use an arrow function?
Trim syntax, useful when you want to
75
In what situations would you not want to use an arrow function?
Constructors, methods