MZ What amount of If Statements is too much?

As stated on my profile, I'm a noob when it comes to Javascript with no real world experience. As I try to develop my game through scripting like adding mechanics and gimmicks, I noticed that I have so many If Statements running during a battle on its update function (meaning this if statements run every frame).

I didn't notice any lag during a battle as my old PC is probably enough to handle it (i3-8100 and GTX 1060). But my goal is to develop an rpg game for mobile first.

What I did to my functions is add another If Statement so that the function that will process my mechanics will only be run once. Here is an example:
JavaScript:
var dontRepeat_processUpdate = 100;

function processUpdateAction()
{
    if(updateActionBoolean)
    {
        var indexAction = $gameActors.actor(actorID)._indexSomething;

        if(dontRepeat_processUpdate != indexAction)
        {
            dontRepeat_processUpdate = indexAction;
           
            updateAction(indexAction); //the process function
        }
    }
}

The function processUpdateAction() is being run at every frame and the function updateAction() will only be run once, as long as indexAction has the same value.

I have like 15-20(not sure) of this if statements always checking conditions in every frame of the battle right now. No lag on my PC, but I still haven't test this on a mobile phone.

My question is, will a hundred of this if statements running on every frame impact the game's performance? How about thousands? I'm just worried about this as I still have many things to add. Thanks!
technically none - but you're asking the wrong question.

the if command itself is rather quick and simple, especially if it is false.
problems might come from the content that is active if it is true - because that can be a lot more processing and take a lot more time.

and that is especially if it goes to a dozen of such statements and they all go active at once.
depending on what exactly those cases do, it might be better to split things up.

for example if you have twenty complex initialisations that only matter after ten frames before the initialisations are not needed, then instead of having everything processed on the first frame I would process four different each on the first five frames. That would still have everything done by the fifth frame, without putting too much calculations into the first frame.

However that cannot work every case, it always depends on what exactly is done inside the not repeated update function. Some of those things have to be processed on the first frame and can't be delayed to a later frame to reduce process load.
That's where you have to decide yourself.
so many If Statements running during a battle
in a battle, everything should process "as is"
"How" is it, you ask? -> it is, *as another process says* it is.

when updating something, don't condition the update.
update *whatever the object's current configuration* is.
what determines that configuration? other processes.
those other processes update outside your update loop, because nothing is really ever "parallel"... everything is just correctly timed, one action after another.
you have to figure out what that order is.
technically none - but you're asking the wrong question.

the if command itself is rather quick and simple, especially if it is false.
problems might come from the content that is active if it is true - because that can be a lot more processing and take a lot more time.

and that is especially if it goes to a dozen of such statements and they all go active at once.
depending on what exactly those cases do, it might be better to split things up.

for example if you have twenty complex initialisations that only matter after ten frames before the initialisations are not needed, then instead of having everything processed on the first frame I would process four different each on the first five frames. That would still have everything done by the fifth frame, without putting too much calculations into the first frame.

However that cannot work every case, it always depends on what exactly is done inside the not repeated update function. Some of those things have to be processed on the first frame and can't be delayed to a later frame to reduce process load.
That's where you have to decide yourself.
So what you're saying is, it didn't matter how many if statements are there, as long as there are sufficient processes in each frame? Another question though.

$gameParty.addActor()
$gameActors.actor(actorID).addState()
$gameMap._events[eventID].moveStraight()

How do I determine which of the functions have higher processing value?

in a battle, everything should process "as is"
"How" is it, you ask? -> it is, *as another process says* it is.

when updating something, don't condition the update.
update *whatever the object's current configuration* is.
what determines that configuration? other processes.
those other processes update outside your update loop, because nothing is really ever "parallel"... everything is just correctly timed, one action after another.
you have to figure out what that order is.
I always view my If Statements inside Update() as listeners. But I guess that is the easiest way to do it as I still lack knowledge of how the engine works. Now that you told me, I'll try avoiding this method as long as I can and rewrite my existing code in the future.

Original thread: https://forums.rpgmakerweb.com/threads/what-amount-of-if-statements-is-too-much.150118/