Pre increment in Javascript
I've just encountered a 'feature' in Javascript regarding pre-increments. In all other languages I've used, it goes like I thought it would. E.g. in C++: #include <iostream> int main() { int i = 0; i += ++i; std::cout << i << std::endl; // Outputs 2. } So, ++i doesn't make copy of the variable, hence the output is 2. Same in PHP: <?php $i = 0; $i += ++$i; echo $i; // Outputs 2. However, in Javascript: var i = 0; i += ++i; console.log(i); // Outputs 1. So it looks like that in Javascript, it makes copy of i and doesn't reference the variable. Is this intentional and if yes, why? From EcmaScript