Skip to content

Instantly share code, notes, and snippets.

@sAbakumoff
Last active October 8, 2016 13:25
Show Gist options
  • Save sAbakumoff/1ef72aad9f997fb10f14aedd48dddf24 to your computer and use it in GitHub Desktop.
Save sAbakumoff/1ef72aad9f997fb10f14aedd48dddf24 to your computer and use it in GitHub Desktop.
// way#1 - adding the element to an arbitrary position
var a1 = new Array();
a1[1000 * 1000 * 1000] = 'a';
a1.length; // 1000000001
// way#2 - setting the length at creation time
var a2 = new Array(1000*1000*1000 + 1);
a2[0] = 'a';
a2.length; // 1000000001
//way#3 - setting length property:
var a3 = new Array();
a3[0] = 'a';
a3.length = 1000*1000*1000 + 1;
a3.length; // 1000000001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment