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
🌐
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 changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
🌐
W3Schools
w3schools.com › jsref › jsref_splice.asp
JavaScript Array splice() Method
Array[ ] Array( ) at() concat() constructor copyWithin() entries() every() fill() filter() find() findIndex() findLast() findLastIndex() flat() flatMap() forEach() from() includes() indexOf() isArray() join() keys() lastIndexOf() length map() of() pop() prototype push() reduce() reduceRight() rest (...) reverse() shift() slice() some() sort() splice() spread (...) toReversed() toSorted() toSpliced() toString() unshift() values() valueOf() with() JS Boolean
Discussions

JavaScript Array splice vs slice - Stack Overflow
The splice() method changes the content of an array by removing existing elements and/or adding new elements. ... This will remove one element from the participantForms array at the index position. These are the Javascript native functions, AngularJS has nothing to do with them. More on stackoverflow.com
🌐 stackoverflow.com
javascript - Splice function on an array of objects - Stack Overflow
I'm doing a react/javascript exercice and i'm having some trouble understanding the use of splice() in it. I have 8 cards, and i need to randomly assign 4 cards to 2 players. Now everything works ... More on stackoverflow.com
🌐 stackoverflow.com
A better way to splice an array into an array in javascript - Stack Overflow
The splice function modifies the array directly, but returns the an array of elements that were removed... not the spliced array. While it's normally not recommended to extend core javascript classes, this is relatively benign with most standard frameworks. More on stackoverflow.com
🌐 stackoverflow.com
Why does array.splice(); works like it works? WHY?
I don't know....I think this one's easy to remember because it's like splicing genes, innit? start here, end there, remove that bit - like you're cutting with a scalpel. More on reddit.com
🌐 r/learnjavascript
68
1
July 5, 2019
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › includes
Array.prototype.includes() - JavaScript | MDN
The includes() method compares searchElement to elements of the array using the SameValueZero algorithm. Values of zero are all considered to be equal, regardless of sign. (That is, -0 is equal to 0), but false is not considered to be the same as 0.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-array-splice-method
JavaScript Array splice() Method - GeeksforGeeks
The splice() method in JavaScript is used to change the contents of an array by removing, replacing, or adding elements.
Published   January 16, 2026
🌐
Substack
soundfly.substack.com › p › choice-overload-in-aisle-five
Choice overload in aisle five - by Ian Temple
1 week ago - The modern DAW is a wonderland of wunder-tools, each better than the last. There are voluminous libraries of instruments, from the cello to the hurdy-gurdy; plugins for every operation imaginable; simulators, samplers, & synthesizers; interfaces that splice, dice, splash, and randomize.
🌐
p5.js
p5js.org › reference › p5 › splice
splice
Copies an array (or part of an array) to another array.
Find elsewhere
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Array methods
It modifies arr starting from the index start: removes deleteCount elements and then inserts elem1, ..., elemN at their place. Returns the array of removed elements. This method is easy to grasp by examples. ... let arr = ["I", "study", "JavaScript"]; arr.splice(1, 1); // from index 1 remove 1 element alert( arr ); // ["I", "JavaScript"]
🌐
W3Schools
w3schools.com › js › js_array_methods.asp
JavaScript Array Methods
The slice() method slices out a piece of an array. The splice() method can be used to add new items to an array:
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]

🌐
freeCodeCamp
freecodecamp.org › news › javascript-splice-how-to-use-the-splice-js-array-method
JavaScript Splice – How to Use the .splice() JS Array Method
April 23, 2021 - It lets you change the content of your array by removing or replacing existing elements with new ones. This method modifies the original array and returns the removed elements as...
🌐
Refine
refine.dev › home › blog › tutorials › how to use javascript array splice
How to Use JavaScript Array Splice | Refine
September 5, 2024 - As we'll start seeing next, splice() mutates the original array and returns an array containing removed items. Although, JavaScript splice() attempts to mutate the caller array, the returned value is an array of removed items.
🌐
Stack Overflow
stackoverflow.com › questions › 56378540 › splice-function-on-an-array-of-objects
javascript - Splice function on an array of objects - Stack Overflow
Its just a way to get the removed element of the array. hand2.splice(randIndex, 1) will return the removed elements from array.
🌐
Kapiinsuranceagency
kapiinsuranceagency.blog › en › education
Los Altos High School vs. Westmont High School
1 week ago - Bagi Anda yang ingin mempersiapkan masa depan keuangan dengan cara yang cerdas dan aman, Kapi Agency memiliki solusi yang tepat untuk Anda. Dengan mengajukan kontrak uang pertanggungan jiwa, Anda bisa meningkatkan penghasilan secara signifikan. Mengapa tidak mencoba cara yang mudah ini untuk ...
🌐
Medium
medium.com › @ryan_forrester_ › javascripts-splice-method-a-complete-guide-c579ff14af7a
JavaScript’s splice() Method: A Complete Guide | by ryan | Medium
November 19, 2024 - Unlike simpler methods that only add or remove elements, splice() lets you modify arrays in place by removing existing elements and inserting new ones simultaneously.
🌐
Thinkpalm
thinkpalm.com › blogs › javascript-splice-other-array-manipulation-methods
JavaScript Splice and other Array Manipulation Methods: ThinkPalm
April 5, 2016 - Finally, you can specify any number of additional optional arguments which represent items to be added to the array. splice() returns an array of removed items. If no items are removed, an empty array is returned. First method that we are going to discuss is push/pop. Push is a method for adding elements to the end of a JavaScript array.
🌐
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 - Let’s see how to add and remove elements with splice( ): For removing elements, we need to give the index parameter, and the number of elements to be removed: ... Index is the starting point for removing elements. Elements which have a smaller index number from the given index won’t be removed: array.splice(2); // Every element starting from index 2, will be removed
🌐
Programiz
programiz.com › javascript › library › array › splice
JavaScript Array splice()
If array.length + start < 0, it will begin from index 0. let languages = ["JavaScript", "Python", "Java", "Lua"]; // does not removes, only appends to the end let removed = languages.splice(5, 2, "C++"); console.log(removed); // [] console.log(languages); // ["JavaScript", "Python", "Java", "Lua", "C++"]
🌐
Scaler
scaler.com › home › topics › javascript array splice() method
JavaScript Array splice() Method - Scaler Topics
April 10, 2024 - The Array splice() method in JavaScript is used to change the elements in an array. It works by adding or removing array elements & overwriting the original array.
🌐
DhiWise
dhiwise.com › post › javascript-array-splice-method-a-detailed-exploration
JavaScript Array Splice Method: A Comprehensive Guide
September 5, 2024 - The JavaScript array splice method is not just about removing elements; it can also be used to add new elements to an array. This is achieved by passing additional arguments after the deleteCount parameter.