Fundamentals Flashcards
What are the 8 main data types?
String, number, bigint, array, object, symbol, null, undefined
What is the difference between null and undefined?
undefined is given to variables not yet given a value, while null is a value that can indicate data missingness.
What values are “Falsy”?
“”
NaN
undefined
null
0
What does a NaN value represent?
Not a Number. A result of an invalid mathematical expression, like 5/“apple”
What values are “truthy”?
Any nonempty string
Any number
An empty array
An empty object
An empty function
Why might you want to use a bigint data type rather than a number data type?
bigint has a higher amount of precision for integers higher than 2*10^53
What is the object data type?
A collection of key values pairs inside curly braces
What is the symbol data type?
Represents a unique identifier that can be used within objects.
What is the difference between assigning a variable with let versus const?
Variables assigned using const can’t be reassigned.
What is the difference between prefixing and postfixing - - and ++?
Prefixing will return the value and then increment it. Postfixing will increment the value and then return it.
How do you find out the type of a variable?
typeof(x) or just typeof x