Created
May 3, 2015 08:00
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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