Data Types In Java Script
Data types which defines the type of an value that stored in the variable. The value may be characters ,strings or any other.
Also Unlike other programming language we have to specify the data types like Int ,string ,Boolean. But in JavaScript it automatically determines the data type based on the given value given to the variable
There is 2 types of data types in JavaScript,
1).Primitive Data Type
2).Non Primitive Data Type
Primitive Data Type
Primitive data type deal with single value. Also in primitive data type the values are stored directly in the memory. Primitive data type is value based.
when we compare the values of primitve data type the value assigned to new variable has a seperate copy of the value this is called deep copy.
In primitive data type alter the value of copied variable does not affect the value of original variable.
Types of primitive data type,
- Number
Number Data Type which is used to store numeric values it includes both whole number and decimal.
Example :
2. String
String is used to store the sequence of characters. We can create string using Double quotes, Single Quotes and Backticks.
Example :
3. Boolean
Boolean stores one of two values true or false .It mainly used to make decisions in program.
Example :
4.Undefined
Undefined represents where the variable is declared but there is no value assigned to the particular variable. Eg ,like saying pick an apple from the bucket when there is no bucket.
Get SANTHOSH KUMAR M’s stories in your inbox
Join Medium for free to get updates from this writer.
Example :
5.Null
Null is used if we dont want to assign any value to the variable. It store in memory but has no value.we can reassign the value when we needed.Eg,picking an apple from the bucket when there is no apple in the bucket
Example :
6. BigInt
It is used to store large whole number.
Example :
Non Primitive Data Type
Non primitive data type store collection of values .It is used in complex data.
Non primitive data type performs shallow copy it copies the address of the value. Also In primitive non data type alter the value of copied variable does affect the value of original variable.
Types of non Primitive data type,
- Object
It used to store values as key value pair
Example :
2. Array
It is used to store multiple values ,the values may of any data type and stored in order and can be accessed by indexing.
Example :
This is about the data types in JavaScript..






