Skip to content

Instantly share code, notes, and snippets.

@RinatMullayanov
Created May 3, 2015 08:00
Show Gist options
  • Save RinatMullayanov/44933f84f167173b9266 to your computer and use it in GitHub Desktop.
Save RinatMullayanov/44933f84f167173b9266 to your computer and use it in GitHub Desktop.
Right using for..in for iterate array. From http://habrahabr.ru/post/247857/
// a - разреженный массив
var a = [];
a[0] = "a";
a[10] = "b";
a[10000] = "c";
for (var key in a) {
if (a.hasOwnProperty(key) &&
/^0$|^[1-9]\d*$/.test(key) &&
key <= 4294967294) {
console.log(a[key]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment