Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Last active February 11, 2020 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllGistsEqual/a34f62f6d3bc3cb5a4a6c010856beecc to your computer and use it in GitHub Desktop.
Save AllGistsEqual/a34f62f6d3bc3cb5a4a6c010856beecc to your computer and use it in GitHub Desktop.
// create a cube from a square
const square = { x: 5, y: 10 }
const cube = { ...square, z: 12 }
console.log(square) // { x: 5, y: 10 }
console.log(cube) // { x: 5, y: 10, z: 12 }
cube.x = 10
console.log(square) // { x: 5, y: 10 }
console.log(cube) // { x: 10, y: 10, z: 12 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment