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?
v is initialized with 2.v++ increments v to 3 and then returns 2.var v = v++; assigns 2 to v (overwrites the 3 in v with the 2 returned from v++).console.log(v) prints 2