0

Invalid left-hand side in postfix operation

this code is wrong, but why? It looks logical to me. Is it wrong because of a specific JS syntax rule? var a=0; alert(++(a++));

10th Apr 2017, 4:49 PM
Simon Nadolski
Simon Nadolski - avatar
2 Respostas
+ 5
This is because ++ and -- operators work on variables not the static numbers. So ++0 or ++1 or 0++ or 1++ any such combination is not valid.
10th Apr 2017, 5:04 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 2
it's a back to future issue in my mind. you should carry out first the operation in the parenthesis but postfix will happen after alert. Edit even without parenthesys it shows the same error so my theory is wrong. Probably just wrong syntax
10th Apr 2017, 5:01 PM
seamiki
seamiki - avatar