Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. {
  2. data: {
  3. info: {
  4. user: {
  5. name: "Hercules",
  6. password: "Iamthegreatest!"
  7. email: "hercules@olymp.gr"
  8. }
  9. }
  10. }
  11. }
  12.  
  13. if (data && data.info && data.info.user && data.info.user.email) {
  14. var email = data.info.user.email;
  15. }
  16.  
  17. if (data.info.user.email)
  18. // do something
  19. }
  20.  
  21. let data = {
  22. info: {
  23. user: {
  24. email: 'user.email@example.com'
  25. }
  26. }
  27. }
  28.  
  29. _.get(data, 'info.user.email');
  30. // => 'user.email@example.com'
  31.  
  32. _.get(data, 'info.user.emailAddress', 'default.email@example.com');
  33. // => 'default.email@example.com'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement