这就是我现在所拥有的:
if (user.userId && _.include(Session.get('onlineEditors'), user.userId)) {
return Meteor.users.findOne({_id: user.userId})
}
现在我想添加一个|| (或)if语句开头的替代方案。比方说,变量currentUserId
。
所以代码会说:如果currentUserId
为真或user.userId && _.include(Session.get('onlineEditors'), user.userId)
为真
如何正确格式化?
答案 0 :(得分:3)
if (currentUserId || (user.userId && _.include(Session.get('onlineEditors'), user.userId)))
答案 1 :(得分:0)
if (currentUserId != null || (user.userId != null &&
_.include(Session.get('onlineEditors'), user.userId)))
这是你的意思吗?