3 min readFrontend
What the heck is the Primitive and Non-Primitive data type???
As a beginner, we all struggle to understand the data type in JavaScript. But it actually really easy to understand. JavaScript largely classified the data type into 2 types.…
- JavaScript

As a beginner, we all struggle to understand the data type in JavaScript. But it actually really easy to understand. JavaScript largely classified the data type into 2 types. Those are Primitive and Non-Primitive data type. In this article, I will describe the Primitive and Non-Primitive data type.
Primitive Data Type
In primitive data type can create or store data directly. But can not modify the value after it’s creation.
Note that the variable in which the primitive value is stored can still be reassigned to a new value shown in example 1. But the existing value can not be changed, that we can see in example 2. So a primitive value can be replaced, but it can’t be directly changed.
Example 1
let value1 = "I love Bangladesh.";
value1 = "You love Bangladesh.";
console.log(value1); // The output is You love Bangladesh.Example 2
let value2 = "Hello!";
value[0] = "T";
console.log(value2); // The output is Hello!Now see what those primitive data types are :
- Number
Any kind of number is a number data type. That could be an integer or floating number.
2. String
A string stores a series of characters like “My name is Shakib.” A string can be any text inside double or single quotes.
3. Null
It does not exist. But not undefined either. That means you don’t want to put anything in your variable, but again you don’t want to keep it undefined. So you have to declare the null variable explicitly. Just like that cost thisIsNull = null .
4. Undefined
When you declare a variable, but you didn’t assign a value. That the variable default value is undefined.
5. Boolean
Boolean has two values. Those are: true and false.
6. Bigint
BigInt is a special numeric type that provides support for integers of arbitrary length.
7. Symbol
It’s a very peculiar data type. Once you create a symbol, its value is kept private and for internal use.
Non-Primitive Data Type
Non-primitive data can not store or create data directly. Unlike primitive data types, non-primitive data can be modified after its creation, shown in example 3. Non-primitive data is stored by reference. An object is a non-primitive data type.
Example 3
const person = {
name : "shakib",
age: 14;
}
person.age = 19;
console.log (person.age); //The output is 19.Object
Everything in javascript is an object except primitive data. An object is a collection of properties, and a property is an association between a name(or key) and a value.
According to the object's definition, we can understand that function and array’s data type is also the object.
That is all about primitive and non-primitive data types. See you another time. :)
What the heck is the Primitive and Non-Primitive data type??? (opens in a new tab) was originally published in The Startup (opens in a new tab) on Medium, where people are continuing the conversation by highlighting and responding to this story.
Originally published on Medium (opens in a new tab).