Created
February 6, 2019 14:01
-
-
Save theuves/b46c6a248f50fefecbcae4bead74c823 to your computer and use it in GitHub Desktop.
FIlter properties of an object.
This file contains hidden or 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
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