const lightSide = ['Yoda', 'Luke Skywalker', 'Obi-Wan Kenobi']
// remove the first element using slice method, creating a new reference
// in this example we don't need to use spread operator
const newLightSide = lightSide.slice(1)
// the original variable wasn't updated
console.log(lightSide)
// ['Yoda', 'Luke Skywalker', 'Obi-Wan Kenobi']
// only the new one was updated
console.log(newLightSide)
// ['Luke Skywalker', 'Obi-Wan Kenobi']
Created
March 20, 2021 13:18
-
-
Save darleykrefta/c0fb67d4419304b939863eaef75b137c 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