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
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]

🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-the-difference-between-array-slice-and-array-splice-in-javascript
What is the difference between Array.slice() and Array.splice() in JavaScript ? - GeeksforGeeks
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 ...
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]
🌐
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.
🌐
Medium
medium.com › @mariacristina.simoes › splice-slice-split-whats-the-difference-cef7c07f2bc
Splice, Slice & Split.. What’s the difference? | by Maria Cristina Simoes | Medium
May 30, 2019 - Unlike split and slice, splice is destructive — meaning it alters the contents of the array. Splice can remove, replace existing elements, or add new elements to an array. Splice alters the existing array, but it will return the removed items ...
🌐
Medium
medium.com › @avinashkumar151199 › slice-and-splice-in-javascript-30e81e4ea997
Slice and Splice in JavaScript?. slice()-: Slice is used to get a new… | by Avinash Kumar | Medium
August 10, 2023 - In b.slice(2, 4) means that you ... portion is ['Apple', 'Pine-Apple']. splice()-: Splice is used to add/remove an element from the given array, it change the original array....
🌐
Simplilearn
simplilearn.com › home › resources › software development › slice vs splice: know the key differences [2024]
Slice vs Splice: Know the Key Differences [2024]
February 21, 2024 - 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
Find elsewhere
🌐
YoungWonks
youngwonks.com › blog › slice-vs-splice
What is the difference between slice and splice? Does splice mean split? How to remove array elements by using splice?
April 15, 2024 - You can learn more about the slice ... In contrast, the splice method, also known as javascript array splice, is used to modify the contents of an array by removing existing elements and/or adding new elements....
🌐
Sophiali
sophiali.dev › javascript-slice-splice
Remembering slice vs splice in JavaScript
And there we have it! 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.
🌐
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.
🌐
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 - First argument is required, second argument is optional. First argument that represent where to start selection. Second argument that represent where to end selection. Splice method changes the original array.
🌐
Medium
sauravkumarsharma.medium.com › slice-vs-splice-in-javascript-13fdfba9e150
slice() vs splice() in JavaScript | by Saurav sharma | Medium
April 7, 2025 - Use when a shallow copy is needed. Retrieve a copy of an array passed into functions without modifying it. The splice() function updates an array by deleting, replacing, or inserting entries at a specified index.
🌐
Quora
quora.com › What-is-the-difference-between-slice-splice-and-split-in-JavaScript
What is the difference between slice(), splice(), and split() in JavaScript? - Quora
Answer (1 of 2): Fundamentally, slice and splice are Array methods (to be called on arrays), while split is a String method (to be called on strings). The slice method is called on an array, and creates a brand new array containing a subsection ...
🌐
Joel Olawanle
joelolawanle.com › blog › slice-vs-splice-javascript-understanding-differences-use
Slice vs. splice in JavaScript: Understanding the differences and when to use them | Joel Olawanle
April 9, 2023 - The slice method returns a new array, while the splice method does not. Using the right array method can make all the difference in your code. slice and splice may have similar names, but they have unique uses that can help you manipulate arrays ...
🌐
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() changes the original array by adding/removing elements. Slice() copies a given part/ /desired elements of an array, does not change the original array. ... Well it's not very helpful when you don't already understand what they do.
🌐
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 - array.splice(index, number of elements, element, element); As an example, I’m adding a and b in the very beginning of the array and I remove nothing: ... Slice( ) and splice( ) methods are for arrays.
🌐
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.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-array-slice-vs-splice-whats-the-difference
JavaScript Array Slice vs Splice: the Difference Explained with Cake
August 11, 2020 - const infiniteCake = ...'?','?','?','?'] As you see, inifinteCake is unmodified. Splice does operations in place, which means it modifies the exisiting array....