If I do:
var a = 1;
console.log(a) // 1
console.log(++a) // 2
console.log(a++) // 2
console.log(a) // 3
So to try make sense of this I would say:
- Assign 1 to
var a. anow is 1. So it prints 1.- Now, INSIDE function
console.logI sum to a 1. So it should print 2. The sum happens BEFORE printing the value. - Why the value 1 is added to a AFTER printing the actual value of a? This is what I don't get.
How JavaScript works so that this can happen?