I noticed that there are two different behaviors in the assignment of an array value, like arr[i] = ++i
.
In C++
int arr[] = {0,0};
int i = 0;
arr[i] = ++i;
cout << arr[0] << ',' << arr[1] << endl;
// the output is 0,1
But in JavaScript
let arr = [0,0]
let i = 0
arr[i] = ++i
console.log(arr)
// the output is [1,0]
Why is there such a difference? I think the behavior of C++ is more natural.