The difference between .splice() and .slice

Jay Wen
2 min readJun 24, 2020

I can’t tell you how many times I forget the difference between “.splice” and “.slice” when I’m doing an algorithm and trying to decide which one to use. So here are some examples to help me and anybody else who struggles with remembering to understand the differences.

.slice()

  • extracts a part of the array and returns the selected elements in a new array.
  • takes in two arguments. First argument is the start and second argument is the end but does not include the given end argument.

--

--

Jay Wen

Hey! I’m a full stack software engineer. Here’s where I document my technical learning and any tips/skills I can share as I continue to learn. :)