Created
February 17, 2021 19:42
-
-
Save jonathan-fielding/8e19ee0fe1ab2bfab84a36f62006ff86 to your computer and use it in GitHub Desktop.
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
function omit(obj, omitList = []) { | |
const result = { ...obj }; | |
omitList.forEach((prop) => { | |
delete result[prop]; | |
}); | |
return result; | |
} | |
const person = { | |
name: 'Jonathan', | |
age: 21, | |
gender: 'male' | |
} | |
const ageOmitted = omit(person, ['age']); | |
console.log(ageOmitted); // Result { name: 'Jonathan', gender: 'male' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment