Skip to content

Instantly share code, notes, and snippets.

@IOIO72
Created May 10, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IOIO72/90b6da603318a8e89d764dfa67cfffdd to your computer and use it in GitHub Desktop.
Save IOIO72/90b6da603318a8e89d764dfa67cfffdd to your computer and use it in GitHub Desktop.
checks key existance before getting key value
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