What does ++ and | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What does ++ and

I encounter code questions with a++, b++, a--, b--, etc. I have no idea what does ++ or -- mean. Can anyone help me? I'm flustered!!!! 😫😫😫😱😱😱

4th Jan 2017, 11:26 PM
Mark
Mark - avatar
5 Answers
+ 9
Those are shorthand operators, for example: (a++) is the same as (a = a + 1 and a += 1) basically it will increment or decrease the variable depending on what operator you use, using -- would obviously decrease it. :)
4th Jan 2017, 11:30 PM
Alex
Alex - avatar
+ 8
One thing to note: Using ++ or -- after a variable will FIRST return the value of the variable and THEN increase/decrease it by 1, if you have ++/-- in front of the variable it's the other way around. Example: a = 5; b = ++a; //now a is 6 and b is also 6 a = 5; b = a++; //a is 6 again, but b is 5 (first a++ returns the value of a, 5 in this case, and after that it increases a by 1)
4th Jan 2017, 11:44 PM
Robobrine
Robobrine - avatar
+ 3
++ make plus 1 to a variable. An example: var x = 2 var y =2 var resu = (x + y) document.write(resu)
7th Jan 2017, 11:02 AM
Finnlukas
0
Thx dude. Phew!
4th Jan 2017, 11:32 PM
Mark
Mark - avatar
0
привет всем
6th Jan 2017, 6:44 PM
Misha Programmer
Misha Programmer - avatar