Skip to content

Instantly share code, notes, and snippets.

@alexaivars
Created February 16, 2017 09:54
Show Gist options
  • Select an option

  • Save alexaivars/ec319eea9a649634cd2c3eacb14b168a to your computer and use it in GitHub Desktop.

Select an option

Save alexaivars/ec319eea9a649634cd2c3eacb14b168a to your computer and use it in GitHub Desktop.
// safly get values from nested object trees 1 // using similar interface as immutable.js
module.exports = (target, path, defaultValue) => path.reduce(
(obj, key) => obj && obj.hasOwnProperty(key) ? obj[key] : null
, target
) || defaultValue;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment