0
guys what do they mean by the switch expression is evaluated once someone please explain how the process unfolds i
as simple as possible thanks in advance
1 Réponse
+ 3
not sure about javascript. But in c++ it looks like this
switch(expression) <- this is evaluated once.
{
~~
}
So if we had
int x;
cin >> x;
switch(1+x) { };
The expression 1+ x would be performed or calculated just the one time. The result is stored and used to compare against the case statements.
I assume javascript switch statements operate in a similar way