Skip to content

Commit d37e624

Browse files
yossydevJosh-Cena
andauthored
Change the second argument deleteCount of Array.prototype.toSpliced to skipCount. (#38805)
* chore: change deleteCount to skipCount * Update index.md --------- Co-authored-by: Joshua Chen <[email protected]>
1 parent 7efdbbe commit d37e624

File tree

1 file changed

+10
-10
lines changed
  • files/en-us/web/javascript/reference/global_objects/array/tospliced

1 file changed

+10
-10
lines changed

files/en-us/web/javascript/reference/global_objects/array/tospliced/index.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ The **`toSpliced()`** method of {{jsxref("Array")}} instances is the [copying](/
1313

1414
```js-nolint
1515
toSpliced(start)
16-
toSpliced(start, deleteCount)
17-
toSpliced(start, deleteCount, item1)
18-
toSpliced(start, deleteCount, item1, item2)
19-
toSpliced(start, deleteCount, item1, item2, /* …, */ itemN)
16+
toSpliced(start, skipCount)
17+
toSpliced(start, skipCount, item1)
18+
toSpliced(start, skipCount, item1, item2)
19+
toSpliced(start, skipCount, item1, item2, /* …, */ itemN)
2020
```
2121

2222
### Parameters
@@ -28,13 +28,13 @@ toSpliced(start, deleteCount, item1, item2, /* …, */ itemN)
2828
- If `start < -array.length` or `start` is omitted, `0` is used.
2929
- If `start >= array.length`, no element will be deleted, but the method will behave as an adding function, adding as many elements as provided.
3030

31-
- `deleteCount` {{optional_inline}}
31+
- `skipCount` {{optional_inline}}
3232

33-
- : An integer indicating the number of elements in the array to remove from `start`.
33+
- : An integer indicating the number of elements in the array to remove (or, to skip) from `start`.
3434

35-
If `deleteCount` is omitted, or if its value is greater than or equal to the number of elements after the position specified by `start`, then all the elements from `start` to the end of the array will be deleted. However, if you wish to pass any `itemN` parameter, you should pass `Infinity` as `deleteCount` to delete all elements after `start`, because an explicit `undefined` gets [converted](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#integer_conversion) to `0`.
35+
If `skipCount` is omitted, or if its value is greater than or equal to the number of elements after the position specified by `start`, then all the elements from `start` to the end of the array will be deleted. However, if you wish to pass any `itemN` parameter, you should pass `Infinity` as `skipCount` to delete all elements after `start`, because an explicit `undefined` gets [converted](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#integer_conversion) to `0`.
3636

37-
If `deleteCount` is `0` or negative, no elements are removed.
37+
If `skipCount` is `0` or negative, no elements are removed.
3838
In this case, you should specify at least one new element (see below).
3939

4040
- `item1`, …, `itemN` {{optional_inline}}
@@ -45,11 +45,11 @@ toSpliced(start, deleteCount, item1, item2, /* …, */ itemN)
4545

4646
### Return value
4747

48-
A new array that consists of all elements before `start`, `item1`, `item2`, …, `itemN`, and all elements after `start + deleteCount`.
48+
A new array that consists of all elements before `start`, `item1`, `item2`, …, `itemN`, and all elements after `start + skipCount`.
4949

5050
## Description
5151

52-
The `toSpliced()` method, like `splice()`, does multiple things at once: it removes the given number of elements from the array, starting at a given index, and then inserts the given elements at the same index. However, it returns a new array instead of modifying the original array. The deleted elements therefore are not returned from this method.
52+
The `toSpliced()` method, like `splice()`, does multiple things at once: it removes the given number of elements from the array, starting at a given index, and then inserts the given elements at the same index. However, it returns a new array instead of modifying the original array. The deleted elements therefore are not returned from this method, but they remain accessible in the original array.
5353

5454
The `toSpliced()` method never produces a [sparse array](/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays). If the source array is sparse, the empty slots will be replaced with `undefined` in the new array.
5555

0 commit comments

Comments
 (0)