Skip to content

Instantly share code, notes, and snippets.

@kangax
Created November 10, 2010 19:33
Show Gist options
  • Save kangax/671368 to your computer and use it in GitHub Desktop.
Save kangax/671368 to your computer and use it in GitHub Desktop.
// Chrome pet peeve with console logging
var arr = [ ];
for (var i = 0; i < 3; i++) {
arr.push(i);
console.log('foo', arr);
}
/*
Actual:
(3) foo [0, 1, 2]
Expected:
foo [0]
foo [0, 1]
foo [0, 1, 2]
*/
@wlmeurer
Copy link

I don't know, man, still a little odd. Checkout that gist above. Also, try this (all one line):

var i=1,arr=[];arr.push(i);console.log(arr);arr.push(i);console.log(arr);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment