javascript-primitives-and-variables Flashcards

1
Q

What is the purpose of variables?

A

Variables are used to store information to be referenced and manipulated in a computer program.

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

How do you declare a variable?

A
  1. var
  2. let
  3. const
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

The (=) assignment operator is used to initialize a variable.

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 can only contain letters, numbers, underscores, or dollar signs.
Variable names must begin with a letter, an underscore (_) or a dollar sign ($).

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 must always be typed with a consistent capitalization of letters.

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

It is used to represent 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

It is used to represent numbers.

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

It is used to represent true or false statements.

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.

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

Use the variable name, the equals sign (also known as the assignment operator), and the new value for that attribute.

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

Undefined means a variable has been declared but has not yet been assigned a value. … On the other hand, Null is assigned to a variable as a representation of no value.

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 add clarity.

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

Give five examples of JavaScript primitives.

A
  1. string
  2. number
  3. boolean
  4. null
  5. undefined
  6. bigint
  7. symbol
How well did you know this?
1
Not at all
2
3
4
5
Perfectly