Skip to content

Instantly share code, notes, and snippets.

@darleykrefta
Created March 20, 2021 13:17
Show Gist options
  • Save darleykrefta/8aab6d060f21ad6039bace194a4ea082 to your computer and use it in GitHub Desktop.
Save darleykrefta/8aab6d060f21ad6039bace194a4ea082 to your computer and use it in GitHub Desktop.
const lightSide = ['Yoda', 'Luke Skywalker', 'Obi-Wan Kenobi']

// define newLightSide with lightSide reference
const newLightSide = lightSide

// remove the first element of the new array created
newLightSide.shift()

// the original variable is updated too, because it is the original reference
console.log(lightSide)
// ['Luke Skywalker', 'Obi-Wan Kenobi']

// variable newLightSide was updated by the reference
console.log(newLightSide)
// ['Luke Skywalker', 'Obi-Wan Kenobi']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment