Last active
September 11, 2017 15:52
-
-
Save renaudtertrais/d541e9d5d4e5614216c1a44cf4ae2dc2 to your computer and use it in GitHub Desktop.
A simple ES7 omit function
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 omit = (keys, obj) => | |
Object.entries(obj) | |
.filter(([ key ]) => !keys.includes(key)) | |
.reduce((acc, [key, value]) => Object.assign({}, acc, { | |
[key]: value, | |
}), {}); | |
omit(['bar'], { foo: 1, bar: 2, baz: 3 }); // { foo: 1, baz: 3 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
demo: https://repl.it/IMd2/0