Array methods

Array.prototype.splice()

Try the free JavaScript compiler

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

NameTypeDescription
startNumberStarting position.
deleteCountNumberCount to remove.
itemsanyInserted 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(","));
JavaScript Reference