J . , jQuery.each() , 10 , 0 ( ). API jQuery.each().
, . length (, ) , 0 -1. .
:
var brand_new_array = new Array();
brand_new_array[10] = "random array value";
console.log:
for(var i in brand_new_array)
console.log(brand_new_array[i]);
10 console.log:
$(brand_new_array).each( function(i,e) { console.log(e) })
10 console.log:
for (var i=0;i<brand_new_array.length;i++)
console.log(brand_new_array[i]);
If you really want to use .each(), you can skip undefined indexes as follows:
$(brand_new_array).each( function(i,e) {
if (this.hasOwnProperty(i)){ console.log(e) }
})
source
share