Created
May 12, 2017 09:51
-
-
Save ncoden/1a5220774c5a5d07cbb6bce0bf67b8db to your computer and use it in GitHub Desktop.
This file contains 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
// Filter an object by its keys | |
exports.objectFilter = function(obj, keys) { | |
var newObj = {}; | |
var newKeys = Object.keys(obj).filter( (key) => { console.log(keys.indexOf(key)); return keys.indexOf(key) !== -1; }); | |
newKeys.forEach((key) => { newObj[key] = obj[key] }); | |
return newObj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment