What is the output of following code?
var a = 10;
console.log(a++);
console.log(++a);
----o----
The output is:
10
12
Post increment operator first prints the value(10
) and then increments a
to 11. Pre increment first increments the value and then prints. So the 11 is first incremented to 12
and then printed to console.