primitives-and-variables Flashcards

1
Q

What is the purpose of variables?

A

Variables store text content in a name.

Variables are containers for storing data

This allows us to be able to reference some variable instead of some possibly long value for snippet string thats complex and long.

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

How do you declare a variable?

A

You declare a variable using the var keyword followed by the name of the variable followed by a semicolon.

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 assign the
${ unknown-value}
to
${ user-defined-name}

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

[azAZ]||[any:number]||
||[any: symbol]||
underscore any entity

JavaScript can handle many types of data.

Since JavaScript treats a dollar sign as a letter, identifiers containing $ are valid variable names:

Using the dollar sign is not very common in js, but professional programmers often use it as an alias for the main function

Strings are written inside double or single quotes. Numbers are written without quotes.

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

a vs A are not considered same.
Case matters.

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 value is text content of some length

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 numerical value can be used for arithmetic

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

a true or false value can be used for making a decision.

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

The = operator is used to assign values/ return 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
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 kind of like a state of nothing but its a possible state of nothing. its allowed to exist. eg. just because a baby has not yet been created or born yet, that doesnt mean baies cant exist, they just dont exist yet.

whereas undefined is also a state of nothing but it CANNOT exist its undefined, theres no way to even to define it if it were to exist.

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

it allows you to correlate meaning to the value.

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
null
symbols?
undefinded?

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