Member-only story

Primitive vs Reference Data Types in JS

#3 of the 40 Essentials of Javascript — Primitive vs Reference Data Types

Indy Seh
3 min readDec 25, 2022
Photo by Markus Spiske on Unsplash

In one my previous articles about Data types, terms primitives stored by value and non-primitives stored by reference were used. It is an important concept to understand if you are new to JS and especially if you are going for JS interview. This article aims to explain what is difference between Primitive Data Types and Reference Data Types.

By the way, I have an Instagram Reel and Youtube Short on this Article, if you guys prefer that, please click here: Call Stack — Insta Reel, Call Stack — Youtube Short.

How Primitives are handled in Javascript

Primitive Data types are — strings, numbers, booleans, undefined, BigInt, symbol and null. When you declare one of these in Javascript; it is stored (in fixed amount of memory available) on a stack. A primitive data type on the stack is identified by the variable name you used for declaration in your program. With each primitive data type you create, data is added to the stack. Confusing? Let's understanding using example of variable a, b below.


let x = 5 // Assign `5` to `x`
let y = x // Copy the value of `x` to `y`
y = 55 // Assign `55`
console.log(x, y) // Value…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Indy Seh
Indy Seh

Written by Indy Seh

Python | Go | Javascript | Typescript | Frontend | Backend

No responses yet

Write a response