Sitemap

JavaScript

3 min readAug 21, 2026

--

Hello guys, I’m back with a new blog. This one might sound somewhat technical. Recently, we started our journey of learning JavaScript. During the session, our mentor asked us a question: “What are the data types available in JavaScript?”

Press enter or click to view image in full size

We randomly answered, “int, string, boolean, etc.” At that time, we learned that this is an important interview question and that the answer should include primitive and non-primitive data types. So, I’m excited to share the data types used in JavaScript.

JavaScript data types are divided into two categories: primitive and non-primitive.

Press enter or click to view image in full size

Primitive

String, Number, BigInt, Boolean, Undefined, Null….

String — A sequence of characters inside quotation marks. “Megasree”

Number — Numerical values, including decimal values.

Boolean — Consists of two values, “true” or “false”, and is mostly used for conditions.

BigInt — Also represents numerical values, but is mainly used for very large whole numbers.

Undefined — A variable has been declared but has not been assigned a value yet.

Null — Represents the intentional absence of a value.

Here, I want to share a real-time example to better understand these two types.

Imagine you have a basket.

The basket exists, but you haven’t put an apple in it yet.

The basket exists, but no value has been assigned. This is termed undefined.

Now imagine the basket exists, and you intentionally say that there is no apple in it.

The basket exists, but we intentionally keep it empty. This is null.

So, primitive data types basically deal with values. Next, let’s move on to non-primitive data types.

Non-Primitive

Press enter or click to view image in full size

Object, Array

Get Megasree R’s stories in your inbox

Join Medium for free to get updates from this writer.

Object — Stores information as key-value pairs.

{
name: Megasree
age: 20
Department: IT
}The left side is the key, and the right side is the value.

A value can be accessed through its key.

Array — An array is used to store multiple values in a single variable. In an array, values are accessed through their index.

In an array, it will compare based on their address.

In primitive data types, a copy of the value is created.

Here, a variable city1 is created, and the value is copied to city2.

Changing city2 does not affect city1.

While in non-primitive data types, both city1 and city2 refer to the same array.

When we change the array through city2, the same array is changed, so city1 also shows samething.

For example:

Primitive

let a = "Dindigul"

let b = a

Value is copied.

Changing b doesn't affect a.

a and b have separate values.

Non-Primitive

let a = ["Dindigul"]

let b = a

Reference is copied.

Changing b can affect a.

a and b refer to the same array.

--

--