arr = [1, 5, 3];
i = 1;
arr[i++] = arr[i++];
what is the result and why?
[1, 3, 3]
This is implementation-dependent, just so happens it gets translated to arr = arr by v8; I won't be surprised if e.g. Rhino or IE's JScript translates it to arr = arr. Like in C/C++, this sort of thing is better avoided in real code.
mvasilkov is right. Results are browser dependent:
as i know equal operator first evaluates expresion on the left: arr and sets i = 2; after that evaluates right side expresion: arr
arr = [1, 5, 3]
i = 1
arr /* i == 2 */ = arr /* i == 3 (the "++" isn't actually relevant here) */