---
title: "Discussion on \"Mutable Object References\" | Hashnode"
description: "Discussion on \"Mutable Object References\". Mutable values are values that can be changed without an entirely new value. In JavaScript objects and arrays are mutable by default. As already said in a previous post about Immutable Primitive Values, there is a fundamental difference in JavaScript..."
url: "https://hashnode.com/posts/mutable-object-references/644f9bd790a163c764822300"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Mutable Object References](https://kcoderk.hashnode.dev/mutable-object-references?utm_source=hashnode&utm_medium=feed)

Mutable values are values that can be changed without an entirely new value. In JavaScript objects and arrays are mutable by default. As already said in a previous post about Immutable Primitive Values, there is a fundamental difference in JavaScript...

May 1, 2023 · 1 min read · kcoderk.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[KCoder](https://hashnode.com/@KristofCoder)

@KristofCoder · Earth

  
[View profile](https://hashnode.com/@KristofCoder)

Creating stuff

## Responses 1

Markdown supported · ⌘↵ to post

[Lukas Gaučas](https://hashnode.com/@projektorius96)

[May 1, 2023](https://hashnode.com/posts/mutable-object-references/644f9bd790a163c764822300/comment/645039fc90a163c764823981)

Keep in mind, particularly with objects and arrays you can achieve immutability with object and array spread operators respectively as follows :

With objects:

```
let a = {x: 1}
let b = {...a}
b.x = 2;
console.log(a.x) // still x === 1
```

With arrays :

```
let a = ["one"]
let b = [...a]
b[0] = "two";
console.log(a.x) // still outputs as "one"
```

Cheers !
