---
title: "Comment by Lukas Gaučas on \"Mutable Object References\" | Hashnode"
description: "Keep in mind, particularly with objects and arrays you can achieve immutability with object and array spread operators respectively as follows : With objects: l"
url: "https://hashnode.com/posts/mutable-object-references/644f9bd790a163c764822300/comment/645039fc90a163c764823981"
---

[Discussion](https://hashnode.com/posts/mutable-object-references/644f9bd790a163c764822300)

Comment [Mutable Object References](https://hashnode.com/posts/mutable-object-references/644f9bd790a163c764822300)

[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 !
