Skip to content
UniCircle
EasyConceptualArrays

slice() vs splice()

Question JS-ARR-001

What is the difference between Array.prototype.slice() and splice()? Which one changes the original array?

Show the explanation

Model answer.

  • `slice(start, end)` returns a new array with the items from start up to (not including) end. The original is untouched. Negative indexes count from the end. arr.slice() is a quick shallow copy.
  • `splice(start, deleteCount, ...items)` changes the array in place: it removes deleteCount items at start, inserts items there, and returns the removed items.
JavaScript
const nums = [10, 20, 30, 40];
nums.slice(1, 3);        // [20, 30]; nums is still [10, 20, 30, 40]
nums.splice(1, 2, 99);   // returns [20, 30]; nums is now [10, 99, 40]

A memory aid: splice inserts (and mutates). In React or Redux state, prefer non-mutating methods (slice, filter, spread, or the newer toSpliced) so the old state is not changed.

Original UniCircle question. Last reviewed 22 Oct 2026.