Skip to content

Instantly share code, notes, and snippets.

@chsami
Last active June 25, 2018 15:50
Show Gist options
  • Save chsami/d78fe00cb491c10e1bc25e5a70b4f7e9 to your computer and use it in GitHub Desktop.
Save chsami/d78fe00cb491c10e1bc25e5a70b4f7e9 to your computer and use it in GitHub Desktop.
shallowCopyExample() {
let product = {
name: 'beef',
price: 10,
category: {
name: 'food',
type: 'meat'
}
};
let shallowCopyOfProduct = product;
console.log('[ShallowCopy] Value before edit: ' + product.name);
shallowCopyOfProduct.name = 'Ross beef';
console.log('[ShallowCopy] value after edit: ' + product.name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment