JavaScript30 day 14: Object and arrays - reference vs copy

Updating a reference to an array/object will update the values in the original array/object. A way around this is to make a copy - there are a few of ways to do this:

Make a copy of an array

  1. Array.prototype.slice()
  2. [].concat(array)
  3. [...arrayName]
  4. Array.from(array)

Make a copy of an object

The file for this exercise is on github.