Pure Functions


.slice() vs. .splice()

slice is a pure function. it doesn’t modify the array, it returns a shallow copy of the modified array. splice on the other hand is an impure function. it modifies the original array and the result is the same everytime you run the function with the same args, because the array gets modfied each time. The state changes.