Actually, this is the question: if you believe https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence , then the increment / decrement operators do not have the highest priority. But in practice, regardless of the form (postfix or prefix - no matter), they are executed earlier than the grouping operator or function call:
function test(i) { console.log(i); return(i); }; let i = 0; i++ + test(i); //1 That is, the variable is incremented by 1 first, then the already increased value is passed to the function, and then, since the postfix increment form, when performing binary addition, its value is used before the increase, that is 0. By wrapping the function in brackets, nothing has changed.
It turned out that the increment was executed earlier than the function, although judging by the priority table, this should not be the case.
Or is it a feature of the interaction of unary and binary operators (in this case, a plus that runs from left to right)? I climbed a bunch of forums - I could not find the answer. I hope someone can explain to me, preferably in simple words;)
i++) is calculated, then the second (test(i)). Then the very addition occurs. What are the priorities of the operators used inside the operands - it does not matter. - Regent