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.