Data Types in JavaScript
What is a Data Type
In computer science and computer programming, a data type or simply type is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support basic data types of integer numbers, floating-point numbers, characters and Booleans.
In simple terms data type clearly means what type of data it is. A number, A character, A String etc
There are 7 primitive data types in JavaScript
1 Number
2 String
3 Boolean
4 undefined
5 null
6 symbol
7 big int
Number Data Type
Number's are always so-called floating point number which means that they always have decimals. Even if we don't see them or don't define them.
Example the value 23 is same as 23.0. But they are both simply the number data type.
String Data Type
String data type are simply a sequence of character and so they're just used for text and always put in quotes (no mater if double or single.)
Boolean Data Type
The Boolean data type is essentially a logical type that can only take one of the logical value true or false. We use bool value to take decisions.
Undefined Data Type
So first undefined is the value taken by a variable that is not yet defined. And the variable that not yet defined is simply just a variable that we declare but without assigning a value. Undefined is basically an empty value
Null Data Type
Null is pretty similar because it also means empty value. We will discuss more about this in future.
Symbol Data Type
Symbol data type was introduced in ES 2015. This data type is not very useful for us. It's simply defines a value that is unique and cannot be changed
Big int
Starting in ES 2020 there is also Big Int. Which is for integers that are too large to be represented by the number type. It's another type for numbers.
Original Link: https://dev.to/gsharma010/data-types-in-javascript-12g6
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To