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
Q

Describe array literal notation.

A

brackets baybee with any data type inside

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

How are arrays different from “plain” objects?

A

all arrays have a length property, even []

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

What number represents the first index of an array?

A

0, big fat zero

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

What is the length property of an array?

A

how long the array is

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

How do you calculate the last index of an array?

A

array.length minus 1

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

What is a function in JavaScript?

A

a set of stuff that performs a task

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

Describe the parts of a function definition.

A

inputs outputs rules, (), {}, function name, parameters, keywords, etc etc etc

var const let for while do

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

Describe the parts of a function call.

A

arguments parameters function name

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

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

A

define makes the function call runs it, calls have no {}

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

What is the difference between a parameter and an argument?

A

arguments are values provided when function is called

parameters are placeholder names for when function is defined

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

Why are function parameters useful?

A

its a placeholder and kinda a formula for later

36
Q

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

A
37
Q

Give 6 examples of comparison operators.

A
38
Q

What data type do comparison expressions evaluate to?

A

boolean

39
Q

What is the purpose of an if statement?

A

it allows us to make conditions

40
Q

Is else required in order to use an if statement?

A

no

41
Q

Describe the syntax (structure) of an if statement.

A

if (conditon) {stuff happens}

42
Q

What are the three logical operators?

A

&&, ||, !

43
Q

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

A

&&, ||

44
Q

Why do we log things to the console?

A

to see wtf is happening, debugging

45
Q

What is a method?

A

actions performed on objects

46
Q

How is a method different from any other function?

A

methods are associated with objects

functions are NOT

47
Q

How do you remove the last element from an array?

A

object.pop()
pop method

48
Q

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

A

math.floor()

49
Q

How do you generate a random number?

A

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
Q

How do you delete an element from an array?

A

splice method

51
Q

How do you append an element to an array?

A

push

generally we add things to ends of arrays

52
Q

How do you break a string up into an array?

A

split

53
Q

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

A

console log it
yes

54
Q

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

A

naw

55
Q

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

A

MDN

56
Q

What is the purpose of a loop?

A

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
Q

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

A

the condition is the breaks. How do we stop the loop?

58
Q

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

A

every single pass thru of the loop code block

59
Q

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

A

before executing the iteration/codeblock

60
Q

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

A

it happens once, before anything.

61
Q

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

A

after initialization, and every time it repeats (before iterations)

62
Q

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

A

end of each loop iteration

63
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 - good for if you’re tryna find 1 value in an array or something

64
Q

What does the ++ increment operator do?

A
65
Q

How do you iterate through the keys of an object?

A

for key in object

66
Q

What is JSON?

A

text based data format

67
Q

What are serialization and deserialization?

A

converts object into string
deserial converts string into object

68
Q

Why are serialization and deserialization useful?

A
69
Q

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

A

json dot parse

70
Q

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

A
71
Q

What is a method?

A

a function which is a property of an object

72
Q

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

A

has the codeblock, call does not

73
Q

Describe method definition syntax (structure).

A

objects property: (function parameters) {codeblock}

74
Q

Describe method call syntax (structure).

A

object.method (arguments)

75
Q

How is a method different from any other function?

A

it’s defined in an object, there’s object . _____

76
Q

What is the defining characteristic of Object-Oriented Programming?

A

objects can contain both data (as properties) and behavior (as methods)

77
Q

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

A

abstraction, encapsulation, inheritance, polymorphism

78
Q

What is “abstraction”?

A

being able to work with complex systems, but in simple ways

79
Q

What does API stand for?

A

application programming interface

80
Q

What is the purpose of an API?

A

a way for 2 or more computers to interact with each other

81
Q

What is this in JavaScript?

A

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
Q

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

A
83
Q

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

A

call time

84
Q

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

A
85
Q

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

A
85
Q

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

A