javascript-primitives-and-variables Flashcards

1
Q

What is the purpose of variables?

A

To temporarily store the bits of information a script needs to do its job

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

How do you declare a variable?

A

Variable keyword, then variable name

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

Variable name, assignment operator (equal sign), variable value

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 (cannot start with a number), dollar sign, underscore

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

Variables that have the same name, but one with an upper case and one with a lower case are considered different variable names (ex: Score and 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

Stores characters and words. To work with any kind of 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

Stores numeric values. For tasks that involve counting or calculating sums; can also determine the size of the screen, move the position of an element on a page, or set the amount of time an element should take to fade in

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

Stores true or false. Determining which part of a script should run (like turning a switch on/off)

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

It is the assignment operator; it says that you are going to assign a value to the variable or update the value given to the variable

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

Write the variable name that you want to change the value for, the assignment operator, and then the new value you want to give 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 represents something (an intentionally empty value) nonexistent or invalid; undefined is automatically assigned to variables that have just been declared or that have no actual arguments.

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 make it clearer which variables are being logged and in what order

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, booleans, undefined, null

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