Why does ‘for’ use ‘;’ between parameters?

I have a question, why does ‘for’ uses ‘;’ between parameters? If could be seen as a function and therefore use ‘,’
for (let counter = 0; counter < 4; counter++)

just wondering

for is not a function, but a statement, a construct consisting of optional expressions and a code block. The expressions are not arguments but controls. The first expression is a declaration which initializes the control variable. The second expression defines the condition under which the loop is permitted to keep running. The final expression is where the value of the control variable is altered by either increasing incrementally or by an amount, or decreasing by one or more.

The semicolon gives the parsing engine a signal to stop and parse the expression before moving on.

Consider that on each iteration the code block is entered with a control value, and exited when the statement(s) within the block have executed. It then executes the value change expression and then evaluates it in the conditional expression. If the condition is still met, the code block is executed again with the new control value.

2 Likes