How to make "ors" in gamescripts

I have this script that goes
$gameParty.leader().actorId() === 4
What if i want it to be === 4 OR 5 OR 34
Is that possible?
I don't know much about JS yet honestly, but || usually stands in for 'or' so probably something like:

if ($gameParty.leader().actorId() === 4 || $gameParty.leader().actorId() === 5 || $gameParty.leader().actorId() === 34) <do whatever here>;

I might be totally wrong, but I thought that might be worth trying until somebody who actually knows JS drops a response. I hope that works (for both of us lol).
oops i forgot to reply
I don't know much about JS yet honestly, but || usually stands in for 'or' so probably something like:

if ($gameParty.leader().actorId() === 4 || $gameParty.leader().actorId() === 5 || $gameParty.leader().actorId() === 34) <do whatever here>;

I might be totally wrong, but I thought that might be worth trying until somebody who actually knows JS drops a response. I hope that works (for both of us lol).
I see i remember now! Yeah, you're right, i tested it and it works, thanks a bunch
That works, but I think you might be able to further simplify it to

Code:
if($gameParty.leader().actorId() == (4 || 5 || 34))
That works, but I think you might be able to further simplify it to

Code:
if($gameParty.leader().actorId() == (4 || 5 || 34))
That won't work. A logical OR like that will return the left value if it's truthy, and the right if the left is falsy. 4 is always truthy so you will never get anything from those parentheses but a 4.
a better one to shorten is:

JavaScript:
let actor = $gameParty.leader().actorId();
if (actor === 4 || actor === 5 || actor === 34) {
//whatever happens here
}

that is the most shorten way I believe.
in this particular case:
Code:
[4,5,6].includes($gameParty.leader().actor().id)

more to the point, in basic Boolean logic:
Code:
A && B == !(!A || !B)
A || B == !(!A && !B)

if you can't have (or, don't know) the operation, reverse the operation and the operands.
instead of having the ID and finding the equivalent, have the control group and find the ID.
2 values, you can tell with a check. 3 values, is an array.... so, use the array properties.
a better one to shorten is:

let Actor = $gameParty.leader().actorId();
if (actor === 4 || actor === 5 || actor 34) {
//whatever happens here
}

that is the most shorten way I believe.
That will also error because you've capitalised the A in Actor but not in actor; you've defined one variable then used one with a different name. You also missed the comparison operator in the last condition.
@Trihan now that you mentioned it, yea, nice catch, should edit it.
so it will be correct for use 🙂

(I corrected it, so no errors probably eanymore =) )

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-ors-in-gamescripts.146263/