Skip to content

Instantly share code, notes, and snippets.

@splincode
Last active April 29, 2019 18:13
Show Gist options
  • Save splincode/0318063da32dd2d435f8fe1e138ae1c1 to your computer and use it in GitHub Desktop.
Save splincode/0318063da32dd2d435f8fe1e138ae1c1 to your computer and use it in GitHub Desktop.
const animals = {
zebra: {
food: ['leaves', 'bark'],
name: 'zebra'
},
panda: {
food: [],
name: 'panda'
}
};
// In order to get a new reference and copy the elements
// we just need to do use spread operator
const copy = { ...animals };
// Alternative:
// const copy = Object.assign({}, animals);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment