Video: Pure Functions, Props, and Nesting React Components in React
Pure functions always return the same result given the same arguments.
Pure function’s execution doesn’t depend on the state of the application.
Pure functions don’t modify the variables outside of their scope.
.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.