Skip to content

Instantly share code, notes, and snippets.

@detj
Created October 24, 2019 09:26
Show Gist options
  • Save detj/c4fdb16c5d99233d6b6013f6627f42de to your computer and use it in GitHub Desktop.
Save detj/c4fdb16c5d99233d6b6013f6627f42de to your computer and use it in GitHub Desktop.
return a new object excluding one key
const source = { a: 1, b: 2, c: 3 }
const toRemove = "c"
const { [toRemove]: toRemove, ...rest } = source
// rest will be { a: 1, b: 2 }
// source remains { a: 1, b: 2, c: 3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment