Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Last active February 7, 2020 16:19
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/986f1524e5e6b277f21b5cac4d27b346 to your computer and use it in GitHub Desktop.
Save AllGistsEqual/986f1524e5e6b277f21b5cac4d27b346 to your computer and use it in GitHub Desktop.
// let's separate Hansel from the rest, he will be put in the cage
const people = { Hansel: { age: 14 }, Gretel: { age: 10 }, Witch: { age: 99 } }
const { Hansel, ...rest } = people
console.log(Hansel) // { age: 14 }
console.log(rest) // { Gretel: { age: 10 }, Witch: { age: 99 } }
// let's draw cards from a deck
const deckOfCards = ['sevenOfClubs', 'aceOfSpades', 'queenOfHearts']
const [topCard, ...restOfCards] = deckOfCards
console.log(topCard) // 'sevenOfClubs'
console.log(restOfCards) // ['aceOfSpades', 'queenOfHearts']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment