---
title: "Comment by JHK Infotech on \"Why the with() method of JavaScript Array is a gem?\" | Hashnode"
description: "Immutable Updates: It creates a new array without altering the original, making it useful in state management. Readability: It provides a clean and concise synt"
url: "https://hashnode.com/posts/javascript-array-method-with-immutability/668bd00b1c0dd730ebc759cd/comment/66e2c46c004a2a333bcc91cf"
---

[Discussion](https://hashnode.com/posts/javascript-array-method-with-immutability/668bd00b1c0dd730ebc759cd)

Comment [Why the with() method of JavaScript Array is a gem?](https://hashnode.com/posts/javascript-array-method-with-immutability/668bd00b1c0dd730ebc759cd)

[JHK Infotech](https://hashnode.com/@himanshu0220)

[Sep 12, 2024](https://hashnode.com/posts/javascript-array-method-with-immutability/668bd00b1c0dd730ebc759cd/comment/66e2c46c004a2a333bcc91cf)

Immutable Updates: It creates a new array without altering the original, making it useful in state management. Readability: It provides a clean and concise syntax for updating elements at specific indexes. Safer: Since it doesn’t mutate the original array, it reduces the risk of side effects in your code. let arr = \[1, 2, 3\]; let newArr = arr.with(1, 5); // \[1, 5, 3\] console.log(arr); // Original array remains \[1, 2, 3\]
