Array Methods
Array.reduce for object
Array.sort for object
Slice and Splice
Slice
Think of "slicing" as cutting a portion out of an array without modifying the original array. slice returns a shallow copy of a portion of an array, specified by a start and end index.
Splice
Think of "splicing" as modifying or changing the original array. splice is used to add or remove elements from an array at a specified index.
Remember the keyword associations: "slice" for creating a new sliced array, "splice" for modifying the original array by splicing in or out elements.
In summary:
slice does not modify the original array and returns a new array.
splice modifies the original array by adding or removing elements.
Last updated