Created
April 4, 2021 03:52
-
-
Save njbmartin/48d1af2ac9b54a35243a7d7224b06511 to your computer and use it in GitHub Desktop.
This file contains 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 person = { | |
firstName: "Jane", | |
lastName: "Bloggs", | |
email: "jane@example.com", | |
phone: "0123456789" | |
}; | |
const omitKey = (data, key) => { | |
const { [key]: _, ...rest } = data | |
return rest | |
} | |
console.log(person.email); | |
// expected output: "jane@example.com" | |
const personWithoutEmail = omitKey(person, "email") | |
console.log(personWithoutEmail.email); | |
// expected output: undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment