JavaScript Flashcards

1
Q

What is the purpose of variables

A

To store info to use later

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

How do you declare a variable?

A

let or var

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

=

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, Numbers, $, _

can’t start with numbers

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

variables are case sensitive

A

True

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

Purpose of strings?

A

store text

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

purpose of numbers?

A

calculations or adjusting CSS

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

purpose of a boolean?

A

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?

A

assignment

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

variable name = new value

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

null vs undefined?

A

Nulls are set intentionally by the developer, whereas undefined is set by JS.
Null may indicate that a value will be assigned eventually.

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 logging values.

A

Good for debugging.

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

5 examples of JS 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

combining strings together into a new string

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

What purpose does the + plus operator serve in JavaScript?

A

Adds numbers together or concatenating strings

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 += do?

A

Adds a value onto a variable, and then stores that new value into the same variable.

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

Operant

A

Value that an operator is operating on

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

What are objects used for?

A

Grouping data that are related to eachother

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

What are object properties?

A

variables in an object

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

Describe object literal notation

A

Key value pairs separated by commas, stored between two curly brackets, and is assigned to a variable. Keys and values are separated with a colon.

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

How do you remove a property from an object?

A

Delete operator then use dot notation to choose the property or method

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

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

A

Dot notation or bracket

25
Q

What are arrays used for?

A

Storing information that is related with each other with an order.
Also used when you don’t know how much space you need.

26
Q

Describe array literal notation.

A

Values separated by commas within square brackets and then assigned to a variable.

27
Q

How are arrays different from “plain” objects?

A

The key is an index number.

28
Q

What number represents the first index of an array?

A

0

29
Q

What is the length property of an array?

A

Tells you how many items is in the array.

30
Q

How do you calculate the last index of an array?

A

You subtract one from the length of the array.

31
Q

Why do we log things to the console?

A

debugging and verification

32
Q

what is a method?

A

A function that is a property of an object.

33
Q

How is a method different from any other function?

A

properties of an object

you can also work with other data part of that object

34
Q

how do you remove the last element from an array

A

pop

35
Q

how do you round a number down to the nearest integer

A

Math.floor()

36
Q

how do you generate a random number?

A

Math.random()

37
Q

How do you delete an element from an array?

A

Splice, pop, shift

38
Q

How do you break a string up into an array

A

.split()

39
Q

Do string methods change the original string?

A

No

40
Q

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

A

~40

41
Q

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

A

~30

42
Q

Use MDN

A

Use MDN

43
Q

Give 6 examples of comparison operators.

A
===
>=
<=
>
<
!==
44
Q

What data type do comparison expressions evaluate to?

A

Boolean

45
Q

What is the purpose of an if statement?

A

Decisions

46
Q

Is else required in order to use an if statement?

A

No

47
Q

Describe the syntax of an if statement

A
conditional statement (condition in parenthesis ) {
 code block in curly brackets
} other conditionals statements if necessary
48
Q

What are the three logical operators?

A

&&, ||, !

49
Q

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

A

logical operators

50
Q

What is the purpose of a loop?

A

To run a set of code one or more times

51
Q

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

A

Tells the loop when to run the code.

Provides a stopping point.

52
Q

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

A

It is every time you run through a loop code block.

53
Q

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

A

It happens before each iteration.

54
Q

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

A

It is the first thing that happens.

55
Q

When does the condition of a for loop get evaluated?

A

It gets evaluated before each iteration.

56
Q

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

A

It gets evaluated after each iteration.

57
Q

Besides return, what keyword exits a function block?

A

break

58
Q

What does the ++ increment operator do?

A

adds one

59
Q

how do you iterate through keys of an object?

A

for in loop