Difference between JavaScript array slice and splice
slice() and splice() methods are part of array object in JavaScript that helps to manipulate an array.
These are some differences between slice and splice listed in tabular form.
Slice | Splice |
---|---|
Doesn’t modify the original array(immutable) | Modifies the original array(mutable) |
Returns the subset of original array | Returns the deleted elements as array |
Used to pick the elements from array | Used to insert or delete elements to/from array |