const ships = ['X-wing', 'TIE Fighter', 'Millenium Falcon']
// define newShips with a spread of ships, creating a new reference
const newShips = [...ships, 'Destroyer']
// the original variable wasn't updated
console.log(ships)
// ['X-wing', 'TIE Fighter', 'Millenium Falcon']
// only the new one was updated
console.log(newShips)
// ['X-wing', 'TIE Fighter', 'Millenium Falcon', 'Destroyer']
Created
March 20, 2021 13:09
-
-
Save darleykrefta/b101372371d4f7dd95a21c8d5716d204 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment