JavaScript Flashcards

1
Q

What is the purpose of variables?

A

variables store primitives like numbers, strings and boolean

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

How do you declare a variable?

A

var keyword

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

equal sign

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 and digits

Must start with a letter, $ or _

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

It means capitalized variable names and non-capitalized variable names are different

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

It stores text

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

It stores value

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

It stores true or false

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

assignment operator

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

use assignment operator again

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

undefined has been assigned but does not have a value. Null is intentionally left blank.

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

for clarity and visibility

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

Give five examples of JavaScript primitives.

A

numbers, strings, boolean, null and undefined

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

adding strings together

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

arithmetic and concatenation

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

addition operator

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

What are objects used for?

A

To store multiple properties in one variable name

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

What are object properties?

A

data of the object

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

Describe object literal notation.

A

starts with variable declaration followed by curly brackets with property names in them.

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

use 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

dot notation or bracket notation

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

What are arrays used for?

A

To keep lists of data and access them

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

Describe array literal notation.

A

brackets and data separated by commas

26
Q

How are arrays different from “plain” objects?

A

They are in order and indexed

27
Q

What number represents the first index of an array?

A

zero

28
Q

What is the length property of an array?

A

it returns how many data are inside the array

29
Q

How do you calculate the last index of an array?

A

subtract one from the length of the array since it starts at zero

30
Q

What is a function in JavaScript?

A

Reusable code block

31
Q

Describe the parts of a function definition.

A

function name, parameter, code block

32
Q

Describe the parts of a function call.

A

functionName(argument)

33
Q

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

A

call is using arguments and definition is using parameters

34
Q

Why are function parameters useful?

A

Because unlike constant values, we can make changes to that one parameter and rest of the code block will change

35
Q

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

A

It returns a value and executes the function

36
Q

Why do we log things to the console?

A

To debug and for data accuracy

37
Q

What is a method?

A

Method is a function that is a property of an object

38
Q

How is a method different from any other function?

A

It is exclusive to the object

39
Q

How do you remove the last element from an array?

A

pop() method of array object

40
Q

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

A

floor) method of Math object

41
Q

How do you generate a random number?

A

random() method of Math object

42
Q

How do you delete an element from an array?

A

Either shift() or splice() method of array object

43
Q

How do you append an element to an array?

A

push() method of array object

44
Q

How do you break a string up into an array?

A

split() method of string object

45
Q

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

A

No it does not. Use console log to check.

46
Q

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

A

A lot. Maybe like 20 to 30.

47
Q

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

A

No

48
Q

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

A

A lot. Maybe like 20 to 30.

49
Q

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

A

MDN

50
Q

What is the purpose of an if statement?

A

Decision making

51
Q

What are the three logical operators?

A

And, Or, Not

52
Q

What is the purpose of a loop?

A

To repeat our desired action

53
Q

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

A

To eventually stop the loop from running forever

54
Q

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

A

To repeat things easily

55
Q

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

A

Before each repetition starts

56
Q

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

A

At the beginning of for loop (only once)

57
Q

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

A

Before each repetition starts

58
Q

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

A

At the end of each repetition

59
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 statement

60
Q

What does the ++ increment operator do?

A

Increments by 1 and updates

61
Q

How do you iterate through the keys of an object?

A

use for in loop (var in object)