Неверное значение в console.log [duplicate]
Possible Duplicate:
Is Chrome's JavaScript console lazy about evaluating arrays?
У меня есть следующие фрагменты в JavaScript, вывод которых заставляет меня чувствовать, что что-то идет не так.
1.
a=2;
console.log(a);
a+=2;
console.log(a);
Output:2 4
; как и ожидалось
2.
t=[0,2];
console.log(t);
t[0]+=2;
console.log(t);
Output: [2,2] [2,2]
Shouldn't the output be [0,2] [2,2]
? And whats the difference between the above two cases that results in the different answers in both the cases?