Skip to content

Instantly share code, notes, and snippets.

@alekstar79
Created October 16, 2023 16:06
Show Gist options
  • Save alekstar79/232d92d9dfbe6fea0462ef7496d0769b to your computer and use it in GitHub Desktop.
Save alekstar79/232d92d9dfbe6fea0462ef7496d0769b to your computer and use it in GitHub Desktop.
function pick(obj, keys) {
return keys.reduce((acc, key) => {
if (obj.hasOwnProperty(key)) {
acc[key] = obj[key]
}
return acc
}, {})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment