JS primitives and variables Flashcards

1
Q

What is the purpose of variables?

A

store bits of information/store data to be used in 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

variable keyword and name of variable

ex) var fullName

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 
ex) var fullName = 'Marley Doughty'
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, $, underscore_, numbers (but CANNOT start with number)

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

uppercase and lowercase are treated as separate entities

ex) fullName !== FullName

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

storing and manipulating 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

math- determine quantities, dimensions, time

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

determine if a value is 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, assigns value to a 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
variable name then assign new value
ex) var totalPets = 2; (new value is 3 pets)
totalPets += 1;
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 intentional absence like a placeholder meaning no value, whereas undefined is an absence of a value , no value has been assigned or the variable has not been declared

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

adds a message in the log that helps maintain organization of variable values, reminds you where it came from (easier to debug)

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