JavaScript: Primitive Data Types Flashcards

1
Q

What are the five main primitive data types?

A

Primitive data types include (1) undefined, (2) string, (3) number, (4) boolean and (5) null

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

Undefined

A

Undefined variables haven’t been assigned values yet.

let myUndefined;

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

String

A

A string is a series of characters and is surrounded by quotes .

const myStringWelcome = “Hello World”;
const myStringPassword = “865Password!2020”;

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

Number

A

A number can be either an integer or a decimal.

const myNumberInt = 100;
const myNumberDecimal = 100.100;

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

Booleans

A

Booleans have two values: true or false.

const isMyBooleanTrue = true;
const isMyBooleanFalse = false;

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

Null

A

Null is both a value and type. It represents the concept of nothing. This differs from undefined, which is an unknown value. Null is known to be nothing.

const myNull = null;

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

How do you check the type of data?

A

To check the type of data, use typeof followed by the name of the variable.

console.log(typeof myUndefined);

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