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. Answer from pookage on reddit.com
๐ŸŒ
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
W3Schools.com
The splice() method adds and/or removes array elements.
Discussions

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
JavaScript Array splice vs slice - Stack Overflow
The splice() methods mutate an array by either adding to the array or removing from an array and returns only the removed items. More on stackoverflow.com
๐ŸŒ stackoverflow.com
A better way to splice an array into an array in javascript - Stack Overflow
The answers above that involve splice.apply and insert the array in a one liner will blow up the stack in a stack overflow for large array. See example here: http://jsfiddle.net/gkohen/u49ku99q/ You might have to slice and and push each item of the inserted and remaining part of the original ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
[AskJS] Would String.prototype.splice be useful?
I don't really ever recommend monkey patching prototypes over introducing your own functions to handle new functionality you want to introduce for a litany of reasons. But I'd still argue the need for a splice method on strings is pretty low, especially when the spread operator can quickly convert to an iterable: [...'0123'].splice(1,2).join('') More on reddit.com
๐ŸŒ r/javascript
20
0
December 18, 2024
๐ŸŒ
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.
๐ŸŒ
DEV Community
dev.to โ€บ justtanwa โ€บ javascript-array-methods-slice-splice-1jb6
JavaScript Array Methods - Slice & Splice - DEV Community
April 8, 2022 - The .splice() changes the array that calls the method and it returns the removed elements from the array. It can also be used to add values to the array at specific index. The method can take many arguments, but the first arguments indicate ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-array-splice-method
JavaScript Array splice() Method - GeeksforGeeks
JS Tutorial ยท Web Tutorial ยท ... 16 Jan, 2026 ยท The splice() method in JavaScript is used to change the contents of an array by removing, replacing, or adding elements....
Published ย  January 16, 2026
Find elsewhere
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Array โ€บ slice
Array.prototype.slice() - JavaScript | MDN
July 20, 2025 - 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.
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ javascript โ€บ splice
JavaScript Splice Method: Array Modification Techniques
The splice() method in JavaScript changes the contents of an array by removing, replacing, or adding elements.
๐ŸŒ
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 - The splice() method is a built-in method for JavaScript Array objects. 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 ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnjavascript โ€บ why does array.splice(); works like it works? why?
r/learnjavascript on Reddit: Why does array.splice(); works like it works? WHY?
July 5, 2019 -

Hello,

so in my honest opinion the Array.prototype.splice makes no sense to me. Why didn't they just add a nice method like "remove" "update" "swap" instead of "splice"? Who's thinking of those stupid names and why did they put all 3 "functions" into this one method?

I've created my own "remove from array" method:

Array.prototype.remove = function(value){
  var index = this.indexOf(value);
  this.splice(index,1);
}

EDIT;
I found something on stack overflow.
https://stackoverflow.com/questions/6515385/alternate-method-to-splice-function-in-javascript

Array.prototype.remove =  function(value, deleteCount) {
  var start = array.indexOf(value);
  var result = [];
  var removed = [];
  var argsLen = arguments.length;
  var arrLen = this.length;
  var i, k;

  // Follow spec more or less
  deleteCount = parseInt(deleteCount, 10);

  // Deal with negative start per spec
  // Don't assume support for Math.min/max
  if (start < 0) {
    start = arrLen + start;
    start = (start > 0)? start : 0;
  } else {
    start = (start < arrLen)? start : arrLen;
  }

  // Deal with deleteCount per spec
  if (deleteCount < 0) deleteCount = 0;

  if (deleteCount > (arrLen - start)) {
    deleteCount = arrLen - start;
  }

  // Copy members up to start
  for (i = 0; i < start; i++) {
    result[i] = this[i];
  }

  // Add new elements supplied as args
  for (i = 3; i < argsLen; i++) {
    result.push(arguments[i]);
  }

  // Copy removed items to removed this
  for (i = start; i < start + deleteCount; i++) {
    removed.push(this[i]);
  }

  // Add those after start + deleteCount
  for (i = start + (deleteCount || 0); i < arrLen; i++) {
    result.push(this[i]);
  }

  // Update original this
  this.length = 0;
  i = result.length;
  while (i--) {
    this[i] = result[i];
  }

  // Return this of removed elements
  return removed;
}
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]

๐ŸŒ
Refine
refine.dev โ€บ home โ€บ blog โ€บ tutorials โ€บ how to use javascript array splice
How to Use JavaScript Array Splice | Refine
September 5, 2024 - In particular, we observe how to wipe out items from a certain index onward. We also go through examples of replacing existing items with new ones. We explore how to insert items in the case of overloaded replacement and injection. We also figure out splice() way of adding items to the tail of the array.
๐ŸŒ
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 - 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.
๐ŸŒ
Codementor
codementor.io โ€บ blog โ€บ javascript splice: what is javascript splice and what can it do?
JavaScript Splice: What is JavaScript Splice and What Can It Do?
June 21, 2022 - The JavaScript splice() method is a built-in method for JavaScript array functions. Splice modifies the original array by removing, replacing, or adding elements. The return value is a new array containing the deleted elements.
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ library โ€บ how-to-use-the-splice-in-javascript
How to Use the Splice in JavaScript (How To) | Treehouse Quick Tips | Treehouse
How to Use the Splice in JavaScript. The first argument in the splice function is the index you want to begin with. The second argument is the numb...
Published ย  May 30, 2013
๐ŸŒ
JavaScript Tutorial
javascripttutorial.net โ€บ home โ€บ javascript array methods โ€บ array.prototype.splice()
JavaScript Array splice(): Delete, Insert, and Replace Elements
November 6, 2024 - How to use the JavaScript Array splice method to delete existing elements, insert new elements, and replace elements in an array.
๐ŸŒ
DhiWise
dhiwise.com โ€บ post โ€บ javascript-array-splice-method-a-detailed-exploration
JavaScript Array Splice Method: A Comprehensive Guide
September 5, 2024 - JavaScript array splice is a built-in method that alters an array's content by removing or adding components.