Array methods
Array.prototype.splice()
Mutates the receiver by replacing a range with supplied items. Returns removed values. With only start supplied, removes through the end; explicit undefined deleteCount becomes zero.
Formal Syntax & Structure
javascript syntaxjavascript
array.splice(start, deleteCount, ...items)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| start | Number | Starting position. |
| deleteCount | Number | Count to remove. |
| items | any | Inserted values. |
Return Value
Array
Removed elements.
Working Example
Example Snippetjavascript
const a=[1,2,3];console.log(a.splice(1,1,9).join(","),a.join(","));