如果 ||(或)声明

How should I format the current if || (or) statement?

本文关键字:声明 如果      更新时间:2023-09-26

这就是我现在拥有的:

  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)是真的

如何正确格式化?

if (currentUserId || (user.userId && _.include(Session.get('onlineEditors'), user.userId)))
if (currentUserId != null || (user.userId != null &&
_.include(Session.get('onlineEditors'), user.userId)))

这是你的意思吗?