javascript-primitives-and-variables Flashcards

1
Q

What is the purpose of variables?

A

Variables are used to store information in a unique name.

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

How do you declare a variable?

A

Variables are declared by using one of the keywords “var”, “const”, or “let” followed by a name, preferably in camelCase.

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

To initialize a variable, a declared variable must be typed, followed by an assignment operator (=), then the value to be assigned must be added.

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

Variable names allow the characters of letters, an underscore, or a dollar sign to begin a name. Additionally numbers can be used in the name, but not to begin the name.

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

Variable names are “case sensitive” meaning that two names with the same exact letters in the same order, but with any of the letters not sharing the same capitalization will create two unique variables. (score and Score are different variable names)

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

The purpose of a string is too carry any type of text. This includes letters, numbers, and special characters.

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

The purpose of a number is to hold all positive numbers, negative numbers, 0, and decimals.

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

The purpose of a boolean is to hold one of two values, true of false. Booleans act as on or off switches.

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 in Javascript means assign the value on the right of the operator to the name on the left of the operator.

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

The value of a variable can be updated if the keywords “var” or “let” was used during the declaration of the variable. At a later point in code, a new value can be reassigned using the assignment operator.

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

The value null is a reference that points to a nonexistent or invalid object or address. The value of undefined is the default value of a declared variable when nothing has been assigned to it. Null is always added by a dev to mean nothing and undefined is always added by JavaScript.

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

If you are console logging multiple things then it can be easy to mistake different values for different variable names.

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

Give five examples of JavaScript primitives.

A

Five examples of JavaScript primitives are: number, string, boolean, null, undefined.

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