Skip to content

Instantly share code, notes, and snippets.

@renaudtertrais
Last active September 11, 2017 15:52
Show Gist options
  • Save renaudtertrais/d541e9d5d4e5614216c1a44cf4ae2dc2 to your computer and use it in GitHub Desktop.
Save renaudtertrais/d541e9d5d4e5614216c1a44cf4ae2dc2 to your computer and use it in GitHub Desktop.
A simple ES7 omit function
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 }
@renaudtertrais
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment