When I do something like this:
var x = 5; console.log( x + (x += 10) );
The difference in the return value between (A) and (B) is explained by the value of x at the time of its calculation. I believe something like this should happen behind the curtains:
TIME
But this is only true if and only if x is evaluated in the same order from left to right that it was written.
So, I have a few questions about this,
Is guaranteed true for all Javascript implementations?
Is it defined in this way as standard?
Or is this some undefined behavior in the Javascript world?
Finally, the same idea can be applied to function calls,
var x = 5; console.log(x += 5, x += 5, x += 5, x += 5);
They are also evaluated in order, but is there a stronger guarantee that this should always happen?
source share