+ 5

prefix and postfix

hi everybody, can somebody explain the error in js: Invalid left-hand side expression in prefix operation? Why things like the following don't work: ++(x+2), (++x)++, ++(x++)

2nd Feb 2018, 10:00 AM
Ognyan Koychev
Ognyan Koychev - avatar
5 Answers
+ 4
.... :) It won't be able bc ++ pre/post fix need to point to variable not the value What I mean? x+2 or ++x or x++ in that case return the "value" which never point to variable at all
2nd Feb 2018, 12:30 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 2
Without bracket it's not working too. This ++x++ leads to error.
2nd Feb 2018, 10:11 AM
Ognyan Koychev
Ognyan Koychev - avatar
+ 1
Very_Hard(asm & js & c++ & java & py & (@Hard)), thank you for the explanation.
2nd Feb 2018, 7:58 PM
Ognyan Koychev
Ognyan Koychev - avatar
0
I think you have to have a variable before/after them. You cannot have a bracket before/after them
2nd Feb 2018, 10:08 AM
Saidmamad Gulomshoev
Saidmamad Gulomshoev - avatar
0
I also once played with these things. Have a look here: https://code.sololearn.com/c1zH4HtI9N53/?ref=app
2nd Feb 2018, 10:19 AM
Saidmamad Gulomshoev
Saidmamad Gulomshoev - avatar