content icon indicating copy to clipboard operation
content copied to clipboard

In the linked page language of the given sentence needs to be more specific it sounds misleading/doesn't make sense

Open sajwan05 opened this issue 9 months ago • 3 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

What specific section or headline is this issue about?

Copying methods and mutating methods

What information was incorrect, unhelpful, or incomplete?

The sentence An easy way to change a mutating method into a non-mutating alternative is to use the [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) or [slice()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) to create a copy first:

Above sentence assumes that we're changing mutating method to non-mutating alternative(language needs to be more specific so learners don't assume), but that's what not we are doing here we are basically copying the array into new array and then applying said method on that new array so we're still mutating that copied array.

What did you expect to see?

I expected to see more clear language about that we are copying the arrays and not changing the method so that they become non-mutating from mutating.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/web/javascript/reference/global_objects/array
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/javascript/reference/global_objects/array/index.md
  • Last commit: https://github.com/mdn/content/commit/dd88a6eb2176fa31f5b744d8964efecf3f1f425b
  • Document last modified: 2026-02-24T22:43:48.000Z

sajwan05 avatar Mar 02 '26 07:03 sajwan05

If this issue gets accepted I would love to work on this issue

sajwan05 avatar Mar 02 '26 07:03 sajwan05

hi, @sajwan05 thank you for reporting this. I'm already on it. @hamishwillee could you pls assign it to me, if needed? once I got assigned, I will merge my PR. thanks

dataCenter430 avatar Mar 02 '26 12:03 dataCenter430

Mutating the intermediate array is not observable because it is not accessible later. On the surface, you simply created a new array. In fact, this is basically how the copying methods are implemented; semantically this is a faithful port.

Josh-Cena avatar Mar 02 '26 17:03 Josh-Cena