DEV Community

Cover image for Data Types in JavaScript
Gaurav Sharma
Gaurav Sharma

Posted on

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.

Image description

🌟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.)

Image description

🌟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.

Image description

Image description

🌟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

Image description

🌟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.

Top comments (0)