There is only one value of this type:
undefined. It is used to represent the concept of an unintentionally missing value.
However, if you try to read a property from this type, you will get a
There is only one such value:
null and it is used for intentionally missing values.
It behaves very similarly to
undefined. For example, it throws an error when you try to access its properties:
null is so similar to
null to represent the intentional absence of a value, which might help distinguish a coding error that could result in
Although it looks like an object, it is a primitive value and does not behave like an
object in any way.
There are only two boolean values:
You can use them to perform logical operations:
This behavior is called floating-point math. It is a way of representing numbers in computers. It is not perfect, but it is sufficient for most cases.
0, the greater the precision of the numbers and the closer they are to each other.
This is because relatively small numbers occur more often in our programs, and we usually want them to be accurate. But when we write
0.2, we don't get exactly
0.1 + 0.2 doesn't give us exactly the same number as writing
This is common to several programming languages. In addition, floating-point math includes some special numbers. For instance, when performing operations such as
Here are some special numbers that might appear in the code:
NaN, which is the result of
0 / 0 and other invalid calculations, stands for "not a number", but it is a number type:
It is rare to write code using these special numbers. However, they can appear because of a coding error. So it is good to know that they exist.
Since regular numbers cannot accurately represent large integers, BigInts were introduced to fill this gap. There is an infinite number of BigInts and they are used to represent integers with arbitrary precision.
BigInts are great for financial application where precision is important. However, keep in mind that operations with huge numbers require time and resources.
Strings have built-in methods, but they are not objects:
Symbols are a new primitive type. They are used to create unique identifiers for objects and control which parts of the code can access it.