Curious case in JavaScript where you get not exactly the most people would expect
function test() {
var v = 2;
var v = v++;
console.log(v);
}
test();
Why the ++
seems ignored here? at what point the ++ operation is executed?
"v++ increments v to 3 and returns 2" what is the first, increment or return?
- if it increments first, the returned value should be "3"
- if it returns first 2, then after that increments, so the incremented value is 2 and v should be 3...