const ships = ['X-wing', 'TIE Fighter', 'Millenium Falcon']
// define newShips with ships reference
const newShips = ships
// push 'Destroyer' value to new array created
newShips.push('Destroyer')
// the original variable is updated too, because it is the original reference
console.log(ships)
// ['X-wing', 'TIE Fighter', 'Millenium Falcon', 'Destroyer']
// variable newShips was updated by the reference
console.log(newShips)
// ['X-wing', 'TIE Fighter', 'Millenium Falcon', 'Destroyer']
Last active
March 20, 2021 13:09
-
-
Save darleykrefta/970e51986a80beb01d5c866fee3f33c8 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