Skip to content

Instantly share code, notes, and snippets.

@vibhasbhingarde
Created July 9, 2018 10:53
Show Gist options
  • Save vibhasbhingarde/53e3fd46c229089736874fefb7fcd15b to your computer and use it in GitHub Desktop.
Save vibhasbhingarde/53e3fd46c229089736874fefb7fcd15b to your computer and use it in GitHub Desktop.
function reject(obj, keys) {
return Object.keys(obj)
.filter(k => !keys.includes(k))
.map(k => Object.assign({}, {[k]: obj[k]}))
.reduce((res, o) => Object.assign(res, o), {});
}
console.log(reject({a: 2, b: 3, c: 4}, ['a', 'b']));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment