Created
July 9, 2018 10:53
-
-
Save vibhasbhingarde/53e3fd46c229089736874fefb7fcd15b 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 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