javascript Flashcards

1
Q

What is the purpose of variables?

A

to store data for the future

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

How do you declare a variable?

A

use a variable keyword to declare the variable then a variable name

“var poopy”

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

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

A

use a =

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

What characters are allowed in variable names?

A

letters, underscores, $, numbers can be used but NOT in the front

Numbered variable names are CRINGE

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

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

A

Score =/= score

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

What is the purpose of a string?

A

way to hold a sequence of characters - preserve text without freaking js out

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

What is the purpose of a number?

A

calculations, MATHS

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

What is the purpose of a boolean?

A

use it to make a choice

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

What does the = operator mean in JavaScript?

A

to assign variables things

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

How do you update the value of a variable?

A

var name then assign it to another variable, no keyword

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

What is the difference between null and undefined?

A

null - intentional absence of a value - it can be defined

undefined - bad - empty that comes from JS. it says “theres nothing here” - means you fucked up

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

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

A

otherwise you don’t know what the console log is for

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

What data type is returned by an arithmetic operation?

A

number

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

What is string concatenation?

A

taking any type of values. that get added to a string, and it all becomes a string.

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

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

A

math and concatenate

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

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

A

they dbz fusion into gotenks

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

What are objects used for?

A

group together variables/properties

what if i need info on more than 1 dog???

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

What are object properties?

A

key + value inside the object

the word & the definition in the dictionary

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

Describe object literal notation.

A

an array of key:value pairs with a comma inbetween, except for the last

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

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

A

brackets or dot for get, same for update

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

What are arrays used for?

A

good for lists of stuff at any length

the order is either EXTREMELY important, or doesn’t matter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe array literal notation.
brackets baybee with any data type inside
26
How are arrays different from "plain" objects?
all arrays have a length property, even []
27
What number represents the first index of an array?
0, big fat zero
28
What is the length property of an array?
how long the array is
29
How do you calculate the last index of an array?
array.length minus 1
30
What is a function in JavaScript?
a set of stuff that performs a task
31
Describe the parts of a function definition.
inputs outputs rules, (), {}, function name, parameters, keywords, etc etc etc var const let for while do
32
Describe the parts of a function call.
arguments parameters function name
33
When comparing them side-by-side, what are the differences between a function call and a function definition?
define makes the function call runs it, calls have no {}
34
What is the difference between a parameter and an argument?
arguments are values provided when function is called parameters are placeholder names for when function is defined
35
Why are function parameters useful?
its a placeholder and kinda a formula for later
36
What two effects does a return statement have on the behavior of a function?
37
Give 6 examples of comparison operators.
38
What data type do comparison expressions evaluate to?
boolean
39
What is the purpose of an if statement?
it allows us to make conditions
40
Is else required in order to use an if statement?
no
41
Describe the syntax (structure) of an if statement.
if (conditon) {stuff happens}
42
What are the three logical operators?
&&, ||, !
43
How do you compare two different expressions in the same condition?
&&, ||
44
Why do we log things to the console?
to see wtf is happening, debugging
45
What is a method?
actions performed on objects
46
How is a method different from any other function?
methods are associated with objects functions are NOT
47
How do you remove the last element from an array?
object.pop() pop method
48
How do you round a number down to the nearest integer?
math.floor()
49
How do you generate a random number?
math.random() random method of the math object it gives you 0 - .999999999999999999, then u multiply by whatev u need to get the rando # u need
50
How do you delete an element from an array?
splice method
51
How do you append an element to an array?
push generally we add things to ends of arrays
52
How do you break a string up into an array?
split
53
Do string methods change the original string? How would you check if you weren't sure?
console log it yes
54
Is the return value of a function or method useful in every situation?
naw
55
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
56
What is the purpose of a loop?
allows you t odo the same t'hing over and over wtihout having to write a lot of code. repeat same codeblock over and over until a condition is met
57
What is the purpose of a condition expression in a loop?
the condition is the breaks. How do we stop the loop?
58
What does "iteration" mean in the context of loops?
every single pass thru of the loop code block
59
When does the condition expression of a while loop get evaluated?
before executing the iteration/codeblock
60
When does the initialization expression of a for loop get evaluated?
it happens once, before anything.
61
When does the condition expression of a for loop get evaluated?
after initialization, and every time it repeats (before iterations)
62
When does the final expression of a for loop get evaluated?
end of each loop iteration
63
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break - good for if you're tryna find 1 value in an array or something
64
What does the ++ increment operator do?
65
How do you iterate through the keys of an object?
for key in object
66
What is JSON?
text based data format
67
What are serialization and deserialization?
converts object into string deserial converts string into object
68
Why are serialization and deserialization useful?
69
How do you serialize a data structure into a JSON string using JavaScript?
json dot parse
70
How do you deserialize a JSON string into a data structure using JavaScript?
71
What is a method?
a function which is a property of an object
72
How can you tell the difference between a method definition and a method call?
has the codeblock, call does not
73
Describe method definition syntax (structure).
objects property: (function parameters) {codeblock}
74
Describe method call syntax (structure).
object.method (arguments)
75
How is a method different from any other function?
it's defined in an object, there's object . _____
76
What is the defining characteristic of Object-Oriented Programming?
objects can contain both data (as properties) and behavior (as methods)
77
What are the four "principles" of Object-Oriented Programming?
abstraction, encapsulation, inheritance, polymorphism
78
What is "abstraction"?
being able to work with complex systems, but in simple ways
79
What does API stand for?
application programming interface
80
What is the purpose of an API?
a way for 2 or more computers to interact with each other
81
What is this in JavaScript?
the value of this is determined by how a function is called (runtime binding). It can't be set by assignment during execution, and it may be different each time the function is called.
82
What does it mean to say that this is an "implicit parameter"?
83
When is the value of this determined in a function; call time or definition time?
call time
84
How can you tell what the value of this will be for a particular function or method definition?
85
How can you tell what the value of this is for a particular function or method call?
85
How can you tell what the value of this is for a particular function or method call?