const droid = {
name: 'R2-D2',
quality: 'resourceful'
}
// define newDroid with droid reference
const newDroid = droid
// update some attribute
newDroid.quality = 'smart'
// variable droid was affected by that change because it is a reference
console.log(droid)
// [object Object] {
// name: 'R2-D2',
// quality: 'smart'
// }
// variable newDroid was updated by the reference
console.log(newDroid)
// [object Object] {
// name: 'R2-D2',
// quality: 'smart'
// }
Created
March 20, 2021 12:59
-
-
Save darleykrefta/ec45efe6ecbc6a21af7f5571f3abe07f 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