Hey,
I’ve just a dumb Javascript question. For example, I want to check, if a user has the property Meteor.user().profile.fullname
. Now there is a point, where Meteor.user() isn’t defined because the user is logging in. At the moment, I’m checking in by the following code (it’s in a autorun):
if(Meteor.user())
{
if(Meteor.user().profile)
{
if(Meteor.usert().profile.hasOwnProperty('fullname');
}
}
This is a little bit long. On some other code I saw something like this:
if(doc&&doc.profile&&doc.profile.name)
But if I do this with Meteor.user()
, I stell get type errors if Meteor.user() isn’t defined.
Is there any pattern how I can reduce my first code?