SHARE
TWEET

Untitled

a guest Jun 18th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top