Created
May 30, 2017 14:21
-
-
Save romuleald/1dc493bfda786538c6fb8eb12ba6f263 to your computer and use it in GitHub Desktop.
filter object keys
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
//accepted = {id: true} | |
//qs = {id: 'lol', kikoo: 'yes'} | |
let filterKeys = function (accepted, qs) { | |
return Object.keys(qs).reduce(function (acc, curr) { | |
if (accepted[curr]) { | |
acc[curr] = qs[curr] | |
} | |
return acc; | |
}, {}) | |
}; | |
//return {id; 'lol'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment