Skip to content

Instantly share code, notes, and snippets.

@romuleald
Created May 30, 2017 14:21
Show Gist options
  • Save romuleald/1dc493bfda786538c6fb8eb12ba6f263 to your computer and use it in GitHub Desktop.
Save romuleald/1dc493bfda786538c6fb8eb12ba6f263 to your computer and use it in GitHub Desktop.
filter object keys
//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