Skip to content

Instantly share code, notes, and snippets.

@miguelrios
Created March 11, 2011 03:29
Show Gist options
  • Save miguelrios/865405 to your computer and use it in GitHub Desktop.
Save miguelrios/865405 to your computer and use it in GitHub Desktop.
var array = [];
console.log("my array has " + array.length + " elements and it looks like: ", array);
console.log("WTF?");
array[5] = 1;
console.log("now my array has " + array.length + " elements and it looks like: ", array);
console.log("Okey...");
/*
results from Chrome-Safari console:
my array has 0 elements and it looks like: [undefined, undefined, undefined, undefined, undefined, 1]
WTF?
now my array has 6 elements and it looks like: [undefined, undefined, undefined, undefined, undefined, 1]
Okey...
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment