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

++x and x++

var x = 5 document.write(x) //5 var y = ++x // x=x+1 and y=x document.write(y) //6 document.write(x) //6 var z = x++ //z=x and x=x+1 document.write(z) //6 document.write(x) //7

26th Dec 2016, 9:34 AM
Helen
Helen - avatar
6 Answers
+ 7
end of line comments are very helpful....thank you
2nd Jan 2017, 1:24 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
+ 4
It is a good example. It's explanation!
26th Dec 2016, 10:12 AM
Emad Tahmoures
Emad Tahmoures - avatar
+ 3
explanation
26th Dec 2016, 10:04 AM
Helen
Helen - avatar
+ 3
It's a pity that some people ask questions in a way other people describe answers. So you can not be sure anymore what it is, but I agree it's a good example :)
26th Dec 2016, 10:14 AM
Andreas K
Andreas K - avatar
+ 1
x ++ increments after using the variable. ++x increments before use.
12th Dec 2019, 11:16 PM
Athanasios vinas
Athanasios vinas - avatar
0
Is this a question or an explanation?
26th Dec 2016, 9:45 AM
Andreas K
Andreas K - avatar