After calculating the result of this code, I wonder if the unary sets my vars as "uno" here to its original state, and if it does, how about negative unaries
let uno = 10, dos = "20", tres = 80;
console.log(++uno + +dos++ + +tres++ - +uno++);
my conclusion was the equation of 103, as 11 + 21 + 81 - 10, but it's appearing not to be true!
The unary operator has lower precedence than the increment operators. So
+dos++is treated as+(dos++). In this case, the unary operator is redundant, because the increment operator converts the value to a number first (it makes little sense to increment a string).Since you're using the post-increment operator on
dosandtres, the values of those subexpressions are the original numeric values; see javascript i++ vs ++i. So you're adding20and30, not21and31.When you subtract
uno++at the end, this happens after the increment from++uno. So the value being subtracted is11, not10.The entire thing is effectively equivalent to: