Array.prototype.splice(start, deleteCount?, ...items) changes an array in place: remove, insert, or replace elements at any index. It returns an array of removed items (often empty). Need a copy without mutation? Use slice() or toSpliced().
Remember
array.splice(start, deleteCount, item1, item2, …)
remove: splice(1, 2)
insert: splice(1, 0, "x", "y")
replace: splice(1, 2, "x", "y")
returns → array of removed items
mutates the original array ✓
slice = copy (safe)
splice = edit in place
Syntax
Call array.splice. Start with this line.
JavaScript
array.splice(start, deleteCount?, …items)
Call
What it does
array.splice(start, deleteCount?, …items)
Primary signature.
array.splice(...)
Call with the arguments your case needs.
Built into JavaScript. Call splice(...) on an array instance — no import required.
Library declarations
JavaScript
array.splice(start, deleteCount?, …items)
Parameters
Parameter
Description
start
Required. Index where changes begin
deleteCount
Optional. How many to remove; omit to delete through the end
...items
Optional. Values to insert at start
Return Value
Return Value
Description
*
Array of removed items (not the array itself)
JavaScript Examples
Example 1 — Remove Elements
Delete two items starting at index 1 and capture what was removed.
Remove first. Drop "banana" and "orange" at index 1.
Insert next. Place "grape" and "melon" in that gap.
One call. Replace is remove + insert together.
Ends stay."apple" and "kiwi" keep their roles at the edges.
Compatibility
Browser & Runtime Support
Array.prototype.splice() has been part of JavaScript since ES3. It is available everywhere arrays are.
✓ Baseline · ES3
Array.prototype.splice()
Supported in every major browser (including Internet Explorer) and all Node.js versions. No polyfill required.
100%Universal support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Array.splice()Excellent
Bottom line: Safe everywhere. For immutable middle-of-array edits in modern engines, prefer toSpliced() (ES2023) when you cannot mutate the source.
Frequently Asked Questions
splice() changes an array in place by removing, inserting, or replacing elements starting at a given index. It returns a new array containing the removed elements (which may be empty).
Yes. splice() modifies the original array. Use slice() when you only need a copy, or toSpliced() (ES2023) for a non-mutating splice-like result.
An array of the removed elements. If nothing was removed, you get []. The modified array is the same reference you called splice on—not the return value.
Set deleteCount to 0: arr.splice(index, 0, newItem1, newItem2). Elements shift right to make room at index.
slice(start, end) extracts a copy without mutating. splice(start, deleteCount, ...items) removes/inserts in the original array and returns removed items. Similar names, opposite immutability.
splice() has been available since ES3 and works in all browsers, including very old environments, and every Node.js version.