Fundamentals Flashcards

1
Q

What are the 8 main data types?

A

String, number, bigint, array, object, symbol, null, undefined

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

What is the difference between null and undefined?

A

undefined is given to variables not yet given a value, while null is a value that can indicate data missingness.

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

What values are “Falsy”?

A

“”
NaN
undefined
null
0

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

What does a NaN value represent?

A

Not a Number. A result of an invalid mathematical expression, like 5/“apple”

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

What values are “truthy”?

A

Any nonempty string
Any number
An empty array
An empty object
An empty function

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

Why might you want to use a bigint data type rather than a number data type?

A

bigint has a higher amount of precision for integers higher than 2*10^53

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

What is the object data type?

A

A collection of key values pairs inside curly braces

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

What is the symbol data type?

A

Represents a unique identifier that can be used within objects.

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

What is the difference between assigning a variable with let versus const?

A

Variables assigned using const can’t be reassigned.

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

What is the difference between prefixing and postfixing - - and ++?

A

Prefixing will return the value and then increment it. Postfixing will increment the value and then return it.

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

How do you find out the type of a variable?

A

typeof(x) or just typeof x

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