JavaScript Flashcards

1
Q

What is the purpose of variables?

A

To contain information for 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
var, let, or const.
var variable = blank;
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

you use the assignment operator.

“=”

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

numbers, _ , $.

You can use numbers, but you cannot start with them.

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

To access a variable, you need to use the exact letter case used in the variable name

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

A string holds text values.

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

A number value can be used for expressions and calculations

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

Boolean gives you true and false options. It allows your code to diverge.

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

This is the assignment operator. It sets one thing equal to another.

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

You assign a new value to the variable

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 is a purposefully void value, while an undefined variable hasn’t been assigned a value yet.

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

labels help you keep track of your console.

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, bigint, boolean, undefined, symbol, and 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

a number value

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

What is string concatenation?

A

when you intermix strings with variable names using the + sign

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

It allows you to add values

17
Q

What data type is returned by comparing two values (, ===, etc)?

A

false or true. A boolean

18
Q

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

A

plus equals, take the current value and adds the new value to it

19
Q

What are objects used for?

A

Objects are used to to transfer info by name

20
Q

What are object properties?

A

the association between name and value

21
Q

Describe object literal notation.

A

var name = {
first: Jacob,
last: Stone
};

22
Q

How do you remove a property from an object?

A

your use the delete operator

23
Q

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

A

bracket or dot notation

24
Q

What are arrays used for?

A

to hold lists or ordered values that can be indexed

25
Q

Describe array literal notation.

A

var name = {
“Jacob”,
“Stone”
};

26
Q

How are arrays different from “plain” objects?

A

it can be indexed

27
Q

What number represents the first index of an array?

A

0

28
Q

What is the length property of an array?

A

the amount of indexes in an array total

29
Q

How do you calculate the last index of an array?

A

array[array.length-1]