diff --git a/files/en-us/web/javascript/reference/global_objects/array/push/index.md b/files/en-us/web/javascript/reference/global_objects/array/push/index.md index 10e660ee4f25b71..8bb5a91f78ad629 100644 --- a/files/en-us/web/javascript/reference/global_objects/array/push/index.md +++ b/files/en-us/web/javascript/reference/global_objects/array/push/index.md @@ -36,7 +36,7 @@ The `push()` method appends values to an array. {{jsxref("Array.prototype.unshift()")}} has similar behavior to `push()`, but applied to the start of an array. -The `push()` method is a mutating method. It changes the length and the content of `this`. In case you want the value of `this` to be the same, but return a new array with elements appended to the end, you can use [`arr.concat([element0, element1, /* ... ,*/ elementN])`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) instead. Notice that the elements are wrapped in an extra array — otherwise, if the element is an array itself, it would be spread instead of pushed as a single element due to the behavior of `concat()`. +The `push()` method is a [mutating method](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#copying_methods_and_mutating_methods). It changes the length and the content of `this`. In case you want the value of `this` to be the same, but return a new array with elements appended to the end, you can use [`arr.concat([element0, element1, /* ... ,*/ elementN])`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) instead. Notice that the elements are wrapped in an extra array — otherwise, if the element is an array itself, it would be spread instead of pushed as a single element due to the behavior of `concat()`. The `push()` method is [generic](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#generic_array_methods). It only expects the `this` value to have a `length` property and integer-keyed properties. Although strings are also array-like, this method is not suitable to be applied on them, as strings are immutable. diff --git a/files/en-us/web/javascript/reference/global_objects/array/shift/index.md b/files/en-us/web/javascript/reference/global_objects/array/shift/index.md index 3e79b4f9cd1edec..5c04d84d9fdf242 100644 --- a/files/en-us/web/javascript/reference/global_objects/array/shift/index.md +++ b/files/en-us/web/javascript/reference/global_objects/array/shift/index.md @@ -31,7 +31,7 @@ values at consecutive indexes down, then returns the removed value. If the The {{jsxref("Array/pop", "pop()")}} method has similar behavior to `shift()`, but applied to the last element in an array. -The `shift()` method is a mutating method. It changes the length and the content of `this`. In case you want the value of `this` to be the same, but return a new array with the first element removed, you can use [`arr.slice(1)`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) instead. +The `shift()` method is a [mutating method](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#copying_methods_and_mutating_methods). It changes the length and the content of `this`. In case you want the value of `this` to be the same, but return a new array with the first element removed, you can use [`arr.slice(1)`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) instead. The `shift()` method is [generic](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#generic_array_methods). It only expects the `this` value to have a `length` property and integer-keyed properties. Although strings are also array-like, this method is not suitable to be applied on them, as strings are immutable.