I have created the following array indexes dynamically
var array=[];
array[4]=[];
array[6]=[];
array[100]=[];
then i have tried to add some data on that indexes
array[4].push({"id":3,"name":"dhaval"});
array[6].push({"id":6,"name":"harsh"});
array[100].push({"id":9,"name":"kevin"});
then when i am using the $.each for retrieving the data the $.each loop throught 0 to 100 .
$.each(array,function(key,item){
console.log(item);
});
the problem is i have to check every time that is item is not undefined then and then the data might exists. so what is the possible solutions for loop only three times not the 100 times.
output :
4 undefined javascript_Each.html:23
[Object] javascript_Each.html:23
undefined javascript_Each.html:23
[Object] javascript_Each.html:23
93 undefined javascript_Each.html:23
[Object]
itemis defined or not