JavaScript Array toSpliced() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

Array.prototype.toSpliced(start, deleteCount?, ...items) returns a new array after removing, inserting, or replacing elements at start. The original array stays unchanged. Same idea as splice(), but immutable—and the return value is the new full array, not the deleted items.

Remember
array.toSpliced(start, deleteCount, item1, item2, …)

remove:  toSpliced(1, 2)
insert:  toSpliced(1, 0, "x", "y")
replace: toSpliced(1, 2, "x", "y")

returns → NEW full array (not deleted items)
original untouched ✓

splice()     → mutates; returns deleted
toSpliced()  → copy; returns new array (ES2023)

Syntax

Call array.toSpliced. Start with this line.

JavaScript
array.toSpliced(start, deleteCount?, …items)
CallWhat it does
array.toSpliced(start, deleteCount?, …items)Primary signature.
array.toSpliced(...)Call with the arguments your case needs.

Built into JavaScript. Call toSpliced(...) on an array instance — no import required.

Library declarations
JavaScript
array.toSpliced(start, deleteCount?, …items)

Parameters

ParameterDescription
startRequired. Index where changes begin
deleteCountOptional. How many to remove; omit to delete through the end
...itemsOptional. Values to insert at start

Return Value

Return ValueDescription
*New array after the remove / insert / replace

JavaScript Examples

Example 1 — Remove Elements

Delete two items starting at index 1 — keep the original array intact.

JavaScript
const fruits = ["apple", "banana", "orange", "kiwi"];

const next = fruits.toSpliced(1, 2);

console.log("next:", next);
// ["apple", "kiwi"]
console.log("fruits:", fruits);
// ["apple", "banana", "orange", "kiwi"]
Try It Yourself

How It Works

  1. Start at index 1. That is "banana".
  2. Delete two in the copy. deleteCount 2 drops "banana" and "orange".
  3. Return value. next is the new full array — not the deleted items.
  4. Original stays. fruits is still all four items.

Example 2 — Insert Without Removing

Set deleteCount to 0 to insert only into a new array.

JavaScript
const fruits = ["apple", "kiwi"];

const next = fruits.toSpliced(1, 0, "pineapple", "peach");

console.log(next);
// ["apple", "pineapple", "peach", "kiwi"]
console.log(fruits);
// ["apple", "kiwi"]
Try It Yourself

How It Works

  1. Zero deletions. Nothing is removed from the copy.
  2. Insert at index 1. "pineapple" and "peach" go in before "kiwi".
  3. New array. next has four elements; assign it to use the result.
  4. Source intact. fruits remains ["apple", "kiwi"].

Example 3 — Replace Elements

Remove two items and insert two different ones in the same spot — on a copy.

JavaScript
const fruits = ["apple", "banana", "orange", "kiwi"];

const next = fruits.toSpliced(1, 2, "grape", "melon");

console.log(next);
// ["apple", "grape", "melon", "kiwi"]
console.log(fruits);
// ["apple", "banana", "orange", "kiwi"]
Try It Yourself

How It Works

  1. Remove first. Drop "banana" and "orange" at index 1 in the copy.
  2. Insert next. Place "grape" and "melon" in that gap.
  3. One call. Replace is remove + insert together.
  4. Original untouched. fruits still has banana and orange.

Browser & Runtime Support

Array.prototype.toSpliced() was added in ES2023 with the other immutable array helpers (toReversed, toSorted, with).

✓ Baseline · ES2023

Array.prototype.toSpliced()

Supported in Chrome 110+, Firefox 115+, Safari 16+, Edge 110+, and Node.js 20+. Not available in Internet Explorer or very old browsers.

92% Modern browsers
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.toSpliced() Good

Bottom line: For older targets, feature-detect with if ("toSpliced" in Array.prototype) or fall back to const copy = arr.slice(); copy.splice(...); return copy;.

Frequently Asked Questions

toSpliced(start, deleteCount?, ...items) returns a new array after removing, inserting, or replacing elements at start. The original array is left unchanged.
No. toSpliced() always returns a new array. Assign the result: const next = arr.toSpliced(1, 2). Ignoring the return does nothing useful.
splice() mutates in place and returns an array of the deleted elements. toSpliced() does not mutate and returns the new full array after the edit—not the deleted items.
Set deleteCount to 0: arr.toSpliced(index, 0, item1, item2). You get a new array with those items inserted; the original stays the same.
Like splice(), omitting deleteCount removes from start through the end of the array in the copy. Prefer passing an explicit deleteCount for clarity.
toSpliced() is ES2023. It works in Chrome 110+, Firefox 115+, Safari 16+, Edge 110+, and Node.js 20+. For older environments, copy with slice/spread then splice the copy.

Next: toString()

Learn how arrays convert to a comma-separated string.

toString() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful