Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

18
  • 270
    Thanks, I thought I would feel stupid for asking but now that I know the answer I don't! Why on earth did they decide to call it splice when a more searchable term was in common use for the same function?! Commented Feb 25, 2009 at 14:46
  • 112
    @tags2k: because the function does more than inserting items and it's name was already established in perl? Commented Feb 25, 2009 at 14:53
  • 18
    doc: developer.mozilla.org/en/JavaScript/Guide/… Commented Mar 10, 2011 at 9:54
  • 76
    Splice can insert, but just as frequently does not. For example: arr.splice(2,3) will remove 3 elements starting at index 2. Without passing the 3rd....Nth parameters nothing is inserted. So the name insert() doesn't do it justice either. Commented May 13, 2014 at 1:45
  • 23
    I think the term "splice" makes sense. Splice means to join or connect, also to change. You have an established array that you are now "changing" which would involve adding or removing elements. You specify where in the array to start, then how many old items to remove (if any) and lastly, optionally a list of new elements to add. Splice is also a great sci-fi term of course. Commented Nov 21, 2014 at 15:45

lang-js