Standard built-ins
Array.prototype.toSpliced()
Returns the edited copy after deleting a range and inserting values. Negative start counts from end; omitted skipCount removes through end when start is supplied. Explicit undefined skipCount converts to zero. Does not return removed elements; retained holes are read as undefined.
Formal Syntax & Structure
javascript syntaxjavascript
array.toSpliced(start?, skipCount?, ...items)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| start | number | Start position, normalized to the array bounds. |
| skipCount | number | Number to remove; omitted with start supplied means through the end. |
| items | any[] | Optional values to insert. |
Return Value
Array
Edited copy.
Working Example
Example Snippetjavascript
const a=[1,2,3]; console.log(a.toSpliced(1,1,8,9).join(","),a.join(","));