splice() changes the original array whereas slice() doesn't but both of them returns array object.

See the examples below:

var array=[1,2,3,4,5];
console.log(array.splice(2));

This will return [3,4,5]. The original array is affected resulting in array being [1,2].

var array=[1,2,3,4,5]
console.log(array.slice(2));

This will return [3,4,5]. The original array is NOT affected with resulting in array being [1,2,3,4,5].

Below is simple fiddle which confirms this:

//splice
var array=[1,2,3,4,5];
console.log(array.splice(2));

//slice
var array2=[1,2,3,4,5]
console.log(array2.slice(2));


console.log("----after-----");
console.log(array);
console.log(array2);

Answer from Thalaivar on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-the-difference-between-array-slice-and-array-splice-in-javascript
What is the difference between Array.slice() and ...
July 12, 2025 - `slice()` creates a new array containing selected elements from the original, while `splice()` modifies the original array by adding, removing, or replacing elements. The slice() method in JavaScript extracts a section of an array and returns ...
Top answer
1 of 16
433

splice() changes the original array whereas slice() doesn't but both of them returns array object.

See the examples below:

var array=[1,2,3,4,5];
console.log(array.splice(2));

This will return [3,4,5]. The original array is affected resulting in array being [1,2].

var array=[1,2,3,4,5]
console.log(array.slice(2));

This will return [3,4,5]. The original array is NOT affected with resulting in array being [1,2,3,4,5].

Below is simple fiddle which confirms this:

//splice
var array=[1,2,3,4,5];
console.log(array.splice(2));

//slice
var array2=[1,2,3,4,5]
console.log(array2.slice(2));


console.log("----after-----");
console.log(array);
console.log(array2);

2 of 16
130

Splice and Slice both are Javascript Array functions.

Splice vs Slice

  1. The splice() method returns the removed item(s) in an array and slice() method returns the selected element(s) in an array, as a new array object.

  2. The splice() method changes the original array and slice() method doesn’t change the original array.

  3. The splice() method can take n number of arguments and slice() method takes 2 arguments.

Splice with Example

Argument 1: Index, Required. An integer that specifies at what position to add /remove items, Use negative values to specify the position from the end of the array.

Argument 2: Optional. The number of items to be removed. If set to 0(zero), no items will be removed. And if not passed, all item(s) from provided index will be removed.

Argument 3…n: Optional. The new item(s) to be added to the array.

var array=[1,2,3,4,5];
console.log(array.splice(2));
// shows [3, 4, 5], returned removed item(s) as a new array object.
 
console.log(array);
// shows [1, 2], original array altered.
 
var array2=[6,7,8,9,0];
console.log(array2.splice(2,1));
// shows [8]
 
console.log(array2.splice(2,0));
//shows [] , as no item(s) removed.
 
console.log(array2);
// shows [6,7,9,0]

Slice with Example

Argument 1: Required. An integer that specifies where to start the selection (The first element has an index of 0). Use negative numbers to select from the end of an array.

Argument 2: Optional. An integer that specifies where to end the selection but does not include. If omitted, all elements from the start position and to the end of the array will be selected. Use negative numbers to select from the end of an array.

var array=[1,2,3,4,5]
console.log(array.slice(2));
// shows [3, 4, 5], returned selected element(s).
 
console.log(array.slice(-2));
// shows [4, 5], returned selected element(s).
console.log(array);
// shows [1, 2, 3, 4, 5], original array remains intact.
 
var array2=[6,7,8,9,0];
console.log(array2.slice(2,4));
// shows [8, 9]
 
console.log(array2.slice(-2,4));
// shows [9]
 
console.log(array2.slice(-3,-1));
// shows [8, 9]
 
console.log(array2);
// shows [6, 7, 8, 9, 0]

Discussions

splice() vs slice() visualized in JavaScript
Thanks I don't understand splice or slice anymore. More on reddit.com
🌐 r/webdev
10
0
July 6, 2020
Splice vs slice in a function
Why does splice work as intended when I input the method above return? function htmlColorNames(arr) { // Only change code below this line // Only change code above this line return arr; } But I I can’t put arr.slice(n1, n2) in the same line? And curiously enough, if I put splice in return ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
September 16, 2022
Why did they design the second parameter of slice() and splice() to mean different things?
I miss the days of confusing substr and substring. More on reddit.com
🌐 r/learnjavascript
10
2
November 2, 2022
On naming conventions and slice vs splice
slice and splice are terrible. I'd much prefer single purpose apis like: clone, removeAt, removeRange, insertAt, insertRange methods. Leads to less bugs because they're more predictable. I don't use slice/splice super often, but when i do, I almost always need to look up which one does what thing. Same goes for "call" and "apply". They are close enough yet different enough that mistakes can easily be made without detection. Case example: Recently checked in a change where I needed a copy of an array, starting at index 1. var myArray = [1, 2, 3]; var arrayWithoutFirstItem = myArray.splice(1); One interesting point here is that splice with a single parameter seems to be handled as a slice call in modern browsers. It does not change the original array, and returns a clone starting at the given index. It worked great on Chrome, FF, and IE11. Passed static code analysis. No bug detected. Until IE8 rolls around and returns null, because really, I should be using slice. More on reddit.com
🌐 r/javascript
8
14
February 28, 2013
People also ask

What is the main difference between slice and splice in JavaScript?
The main difference is that slice() creates a new array with a portion of elements copied from the original array, while splice() mutates the original array itself by removing, replacing or adding elements to it.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › slice vs splice: know the key differences [2024]
Slice vs Splice: Know the Key Differences [2024]
Can splice be used to add new elements to an array?
Yes, splice() can be used to add new elements by specifying the new elements as additional arguments after the deleteCount parameter. For example: let fruits = ['apple', 'mango']; fruits.splice(1, 0, 'orange'); // insert orange at index 1  // fruits is now ['apple', 'orange', 'mango']
🌐
simplilearn.com
simplilearn.com › home › resources › software development › slice vs splice: know the key differences [2024]
Slice vs Splice: Know the Key Differences [2024]
How do you use slice to extract elements from an array?
To extract elements from an array using slice(), you specify the begin and optional end indexes. For example: let fruits = ['apple', 'orange', 'mango']; let citrus = fruits.slice(1, 2); // extract 1 element starting at index 1  // citrus contains ['orange']
🌐
simplilearn.com
simplilearn.com › home › resources › software development › slice vs splice: know the key differences [2024]
Slice vs Splice: Know the Key Differences [2024]
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › splice
Array.prototype.splice() - JavaScript | MDN
July 10, 2025 - The splice() method of Array instances ... a segment removed and/or replaced without mutating the original array, use toSpliced(). To access part of an array without modifying it, see slice()....
🌐
Simplilearn
simplilearn.com › home › resources › software development › slice vs splice: know the key differences [2024]
Slice vs Splice: Know the Key Differences [2024]
3 weeks ago - Confused about JavaScript's slice & splice? Our guide clarifies differences & uses with practical examples. Elevate your coding skills by mastering these methods!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Reddit
reddit.com › r/webdev › splice() vs slice() visualized in javascript
r/webdev on Reddit: splice() vs slice() visualized in JavaScript
July 6, 2020 - Splice vs Slice in #javascript. Splice() changes the original array by adding/removing elements.
Find elsewhere
🌐
Educative
educative.io › answers › splice-vs-slice-in-javascript
splice vs. slice in JavaScript
slice returns a piece of the array but it doesn’t affect the original array. splice changes the original array by removing, replacing, or adding values and returns the affected values.
🌐
Will Vincent
wsvincent.com › javascript-array-slice-vs-splice
JavaScript Arrays: slice vs splice | Will Vincent
April 28, 2017 - Under-the-hood something much more fundamental is going on with the method returns. slice() creates a brand new array object which it then returns; by contrast, splice() mutates the original array object and returns it.
🌐
freeCodeCamp
freecodecamp.org › news › lets-clear-up-the-confusion-around-the-slice-splice-split-methods-in-javascript-8ba3266c29ae
Let’s clear up the confusion around the slice( ), splice( ), & split( ) methods in JavaScript
October 9, 2018 - The name of this function is very similar to slice( ). This naming similarity often confuses developers. The splice( ) method changes an array, by adding or removing elements from it.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-slice-and-splice-how-to-use-the-slice-and-splice-js-array-methods
How to Use the slice() and splice() JavaScript Array Methods
April 13, 2022 - Unlike the slice() method, the splice() method will change the contents of the original array. The splice() method is used to add or remove elements of an existing array and the return value will be the removed items from the array.
🌐
Medium
kat-leight.medium.com › slice-vs-splice-a9503ac55e5e
Slice vs Splice
April 27, 2021 - Unlike the lovely SLICE method, SPLICE is DESTRUCTIVE!
🌐
Dasha
dasha.ai › blog › javascript-arrays-slice-and-splice
Dasha | Slice and Splice JavaScript Arrays Like a Pro
December 7, 2021 - The slice() method is very useful for cloning an array, copying a portion of an array, and converting an array-like object into an array. The splice() method in Javascript helps you add, update, and remove elements in an array.
🌐
DEV Community
dev.to › codepumps › what-is-the-difference-splice-slice-and-split-method-in-javascript-3mll
What is the difference splice, slice, and split method in Javascript ? - DEV Community
November 5, 2020 - Sometimes we want to remove items ... remove more than one item or add to the array. Split() method is used for strings array, slice() method is used for both arrays and strings....
🌐
Tpiros
tpiros.dev › blog › slice-vs-splice
slice vs splice - Tamas Piros
November 17, 2021 - slice() returns a new array containing the elements extracted, as also seen above in the embedded environment. Splice on the other hand has a slightly different signature and it does modify the original array by removing and/or replacing elements ...
🌐
To The New
tothenew.com › home › javascript : array.splice() vs array.slice()
JavaScript Array.splice() vs Array.slice() | TO THE NEW Blog
November 29, 2016 - 1. The splice() method returns the removed item(s) in an array and slice() method returns the selected element(s) in an array, as a new array object.
🌐
Sophiali
sophiali.dev › javascript-slice-splice
Remembering slice vs splice in JavaScript
June 18, 2020 - This blog goes over the differences between slice and splice. You now know that slice makes a shallow copy of the original array, while splice mutates the original array and optionally adds or removes elements.
🌐
Codecademy
codecademy.com › forum_questions › 4f5ea4740ff47b000301a2f4
Why do slice and splice methods take a different second argument? | Codecademy
So, the splice method takes 2 arguments: the index position to start at and the number of items to remove. The slice method also takes 2 arguments: t...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › slice
Array.prototype.slice() - JavaScript | MDN
The slice() method of Array instances returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.