---
title: "What is the reference of an object in JavaScript?"  
description: "What is the reference of an object in JavaScript?"  
author: "Ashutosh Patel"  
published: 2024-12-19  
updated: 2025-01-01  
canonical: https://www.mindstick.com/forum/161067/what-is-the-reference-of-an-object-in-javascript  
category: "javascript"  
tags: ["javascript", "javascript object"]  
reading_time: 1 minute  

---

# What is the reference of an object in JavaScript?

What is the [reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php) of an object in JavaScript?

## Replies

### Reply by Khushi Singh

In JavaScript, the reference of an object is a pointer or reference to the memory location of an object. When you assign or pass an object what you are passed is not the actual object but a reference to the object.

Example:

```javascript
let obj1 = { name: 'Alice' };
let obj2 = obj1; // obj2 holds the reference to the same object
obj2.name = 'Bob';
console.log(obj1.name); // Output: 'Bob'
```

Key Points:\

- All objects are passed by references and not by values.
- Modifying the object via one reference causes changes for all other references of the same object.
- Basic data types, numbers, or strings, are passed and stored in the way of value, not references.

This is why objects in JavaScript behave differently than primitives when assigned or passed in code.\
\
Explore more about [objects in javascript](https://www.mindstick.com/articles/1047/java-script-objects)


---

Original Source: https://www.mindstick.com/forum/161067/what-is-the-reference-of-an-object-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
