Skip to content

Instantly share code, notes, and snippets.

@micahriggan
Created April 27, 2018 15:40
Show Gist options
  • Save micahriggan/1470cf6195fe91148380c2a0e6502b29 to your computer and use it in GitHub Desktop.
Save micahriggan/1470cf6195fe91148380c2a0e6502b29 to your computer and use it in GitHub Desktop.
function filterObj(toFilter, filterKeys) {
return Object.entries(toFilter)
.filter(([key, value]) => filterKeys.includes(key))
.reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment