const darkSide = ['Darth Vader', 'Darth Sidious', 'Supreme Leader Snoke']
// remove the last element using slice method, creating a new reference
// in this example we don't need to use spread operator
const newDarkSide = darkSide.slice(0, darkSide.length - 1)
// the original variable wasn't updated
console.log(darkSide)
// ['Darth Vader', 'Darth Sidious', 'Supreme Leader Snoke']
// only the new one was updated
console.log(newDarkSide)
// ['Darth Vader', 'Darth Sidious']
Created
March 20, 2021 13:14
-
-
Save darleykrefta/4dc42a7eadd8b28fa35ef8dbc0bca0d3 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