Data Types
Data Types
The number type represents both integer and floating point numbers.
There are many operations for numbers, e.g. multiplication, division, addition,
subtraction, and so on.
Besides regular numbers, there are so-called special numeric values which also
belong to this data type:
1. Infinity
2. -Infinity
3. NaN (Not a Number)
BIGINT:
In JavaScript, the "number" type cannot safely represent integer values larger than
2^53 -1 (thats 9007199254740991), or less than -(2^53 -1) for negatives.To be
really precise, the "number" type can store larger integers (up to
1.7976931348623157 * 10^308), but outside of the safe integer range, there will be
a precision error, because not all digits fit into the fixed 64-bit storage. So an
"approximate" value may be stored.
The BigInt type was recently added to the language to represent integers of
arbitrary length.
A BigInt value is created by appending "n" to the end of an integer.
STRING:
1. If you use double quotes, the only other quotes you can use are single
quotes, which will mainly be used for contractions.
2. If you use single quotes, it will throw an error if you try and use
contractions such as wasn't because a contraction uses a single quote.
3. If you use the backticks, you have two other types of quotes available as
well as the fuctionality to use the ${ } straight away.
In JavaScript, there is not character type. There is only one type which is known
as string. A string may be empty, or have one or more characters.
BOOLEAN:
The boolean type has only two values: true and false.
This type is commonly used to store yes/no values: true means "yes/correct" and
false means "no/incorrect".
The special null value does not belong to any of th etypes described above. It
forms a separate type of its own which contains only the null value.
The special value "undefined" also stands apart. It makes a type of its own, just
like null.
The meaning of undefined is "value is not assigned".
If a variable is declared, but not assigned, then its value is undefined.
Technically it is possible to explicitly assign undefined to a variable, but it is
not recommended. Normally, one uses null to assign an "empty" or "unknown" value to
a variable, while undefined is reserved as a default initial value for unassigned
things.
All other types are called "primitive" because their values can contain only a
single thing (be it a string or a number or whatever). In contrast, objects are
used to store collections of data and more complex entities.
The symbol type is used to create unique identifers for objects. We have to mention
it here for the sake of completeness, but also postpone the details till we know
objects.
The typeof operator returns the type of an operand. It is useful when we want to
process values of different types differently or just want to do a quic