Created
May 10, 2019 14:31
-
-
Save IOIO72/90b6da603318a8e89d764dfa67cfffdd to your computer and use it in GitHub Desktop.
checks key existance before getting key value
This file contains 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
const getKeyValueSafely = (obj, key) => ( | |
obj.hasOwnProperty(key) ? obj[key] : undefined | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment