Saturday 22 April 2017

How to check object null and then property null and then assign value if they are null?

I am trying to check if a variable is null inside an object in single line

 let data = {                        
   friends: userData.social.friends?0: userData.social.friends,
}

in the above line how to check if the userData is null and social is null and then friend is null in a single line? i need to set 0 if friends is not there.

this is in my javascript node js app



via face turn

No comments:

Post a Comment