What is ++a is a=6 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is ++a is a=6

I lose too much point there

16th Apr 2017, 1:46 PM
Moonty B. Francis
Moonty B. Francis - avatar
5 Answers
+ 11
if a = 6 and you do ++a, a becomes 7. If you can post the entire question, that would be better. There might be a catch somewhere.
16th Apr 2017, 1:51 PM
Hatsy Rei
Hatsy Rei - avatar
+ 11
I'm not good at JS syntax, sorry if I do some mistakes. e.g. a = 6; document.write(++a); // outputs 7 a = 6; document.write(a++); // outputs 6 This is because a++ (post increment) uses value of var first before incrementing. While ++a increment value of var first before using it.
16th Apr 2017, 1:55 PM
Hatsy Rei
Hatsy Rei - avatar
+ 7
++a/--a is pre-increment, it immediately modifies the value of a before using it (if required) in the statement. a++/a-- is post-increment, it only modifies the value after using it (if required) in the statement.
16th Apr 2017, 2:44 PM
AtK
+ 1
got it 😃😃😃 awesome. no need for Google. thanks for refreshing my memory
16th Apr 2017, 1:58 PM
Moonty B. Francis
Moonty B. Francis - avatar
0
why about a++
16th Apr 2017, 1:52 PM
Moonty B. Francis
Moonty B. Francis - avatar