First, let's look at how values are passed, copied, and stored in memory by JavaScript.

In JavaScript, there are two types of Values.

  1. Primitive Values

This is the data that has a single value and no additional methods or properties. E.g. String, Number, Boolean, Undefined, and Null. These data types are passed by value.

2. Reference Values

All Objects in JavaScript are reference types. E.g. Objects, Arrays, Classes, etc. These data types are passed by reference.

When we assign a primitive value to a variable, the actual data is stored in a memory called the “STACK” and the variable holds…

Akshay Shegaonkar

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store