Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. // check for empty objects/variables
  2. isEmpty = value =>
  3. value === null ||
  4. value === undefined ||
  5. value === "undefined" ||
  6. value.length === 0 ||
  7. value === {};
  8.  
  9. // access the nested variables or return null if undifined or doesn't exist
  10. getNested = (p, o) => p.reduce((xs, x) => (!this.isEmpty(xs) && !this.isEmpty(xs[x]) ? xs[x] : null), o);
Add Comment
Please, Sign In to add comment