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.
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
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()....
🌐
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.
🌐
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 - If nothing was removed from the array, then the return value will just be an empty array. Here is the basic syntax. splice(start, optional delete count, optional items to add)
🌐
W3Schools
w3schools.com › jsref › jsref_splice.asp
JavaScript Array splice() Method
The splice() method overwrites the original array. The Array toSpliced() Method · The Array slice() Method · array.splice(index, count, item1, ....., itemX) // Create an Array const fruits = ["Banana", "Orange", "Apple", "Mango"]; // At position ...
🌐
Go Make Things
gomakethings.com › the-difference-between-the-array.slice-and-array.splice-methods-in-vanilla-js
The difference between the Array.slice() and Array.splice() methods in vanilla JS | Go Make Things
The slice() method always creates a new array, so the original array remains intact. // logs ["Gandalf", "Radagast", "Saruman", "Alatar"] console.log(wizards); The Array.splice() method, on the other hand, is used to add, remove, and replace ...
Find elsewhere
🌐
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.
🌐
Medium
kat-leight.medium.com › slice-vs-splice-a9503ac55e5e
Slice vs Splice
April 27, 2021 - I’ve been doing a lot of algorithms practice lately and I know that both slice and splice are vaguely floating out in the JavaScript universe. . . but I can never remember how to use them. So, I decided to put them both in terms I can understand and remember: baking. ... Slice returns a new array of selected elements that you’ve sliced out of an old 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
🌐
Medium
medium.com › @ensallee › javascript-array-methods-splice-vs-slice-722811d3d540
JavaScript Array Methods: .splice() vs .slice() | by Betsy Sallee | Medium
August 25, 2018 - I’ve also included two solutions to the common chunking algorithm: one makes use of .splice(), and the other makes use of .slice(). ... The .splice() method is a destructive array method, which means it modifies the array on which it is called (disclaimer: destructive methods can be risky, especially if you use the array in question elsewhere in your program, so proceed with caution).
🌐
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 - slice creates a new array containing the specified subset of elements, while splice modifies the original array directly.
🌐
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....
🌐
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.
🌐
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.
🌐
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 - If start is -ve, the elements are ...'?','?','?','?'] As you see, inifinteCake is unmodified. Splice does operations in place, which means it modifies the exisiting array....
🌐
Sophiali
sophiali.dev › javascript-slice-splice
Remembering slice vs splice in JavaScript
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.
🌐
Refine
refine.dev › home › blog › tutorials › how to use javascript array splice
How to Use JavaScript Array Splice | Refine
September 5, 2024 - Use the method splice() when you want to alter an array by removing, inserting, or replacing elements and use the method slice() when you want to retrieve a part of the array without having to change the array.