Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // check for empty objects/variables
- isEmpty = value =>
- value === null ||
- value === undefined ||
- value === "undefined" ||
- value.length === 0 ||
- value === {};
- // access the nested variables or return null if undifined or doesn't exist
- 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