Running on the latest Google Chrome browser (Version 22.0.1229.79) on an iMac with Mountain Lion, you may encounter unexpected results when executing the following code snippet:
var arr = [1, 3, 5];
console.log(arr);
delete arr[1];
console.log(arr);
console.log(arr.pop());
console.log(arr);
The output displayed will be:
[1, undefined × 2]
[1, undefined × 2]
5
[1, undefined × 1]
Interestingly, Firefox exhibits a similar behavior in certain scenarios. Is this an issue with both Chrome and Firefox or does it stem from the use of array delete and console.log
? It seems unlikely that both browsers would have the same bug. Perhaps, there is something unique about how console.log
interacts with arrays.