Skip to content

Instantly share code, notes, and snippets.

@theuves
Created March 9, 2019 17:05
Show Gist options
  • Save theuves/9d8b1e778ae514da17f3904d78d1bdc5 to your computer and use it in GitHub Desktop.
Save theuves/9d8b1e778ae514da17f3904d78d1bdc5 to your computer and use it in GitHub Desktop.
function filterObj(obj, cb) {
const newObj = {};
const entries = Object.entries(obj);
for (entry of entries) {
const [key, val] = entry;
if (cb(key)) {
newObj[key] = val;
}
}
return newObj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment