Created
October 24, 2019 09:26
-
-
Save detj/c4fdb16c5d99233d6b6013f6627f42de to your computer and use it in GitHub Desktop.
return a new object excluding one key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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