Skip to content

Instantly share code, notes, and snippets.

@theuves
Created February 6, 2019 14:01
Show Gist options
  • Save theuves/b46c6a248f50fefecbcae4bead74c823 to your computer and use it in GitHub Desktop.
Save theuves/b46c6a248f50fefecbcae4bead74c823 to your computer and use it in GitHub Desktop.
FIlter properties of an object.
function filterProps(obj, props) {
var newObj = {}
var keys = Object.keys(obj);
for (var i in keys) {
var key = keys[i]
if (props.includes(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