Skip to content

Instantly share code, notes, and snippets.

@sophistifunk
Created May 26, 2017 08:27
Show Gist options
  • Save sophistifunk/d512117c5eb1a9eca3fa8ae88a35431c to your computer and use it in GitHub Desktop.
Save sophistifunk/d512117c5eb1a9eca3fa8ae88a35431c to your computer and use it in GitHub Desktop.
let arr = [10, 11, 12, 13];
console.log(arr.length); // 4
arr.foo = "bar";
console.log(arr.length); // 4
console.log(1 in arr); // true
console.log(arr[10] === undefined); // true
console.log(10 in arr); // false
arr[12] = "thirteenth value";
console.log(arr.length); // 13
console.log(arr[10] === undefined); // still undefined
console.log(10 in arr); // false <-- does not create empty properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment