the console issues the following object
every nested object has a gid property. how do i get an array from this property?
gid=[] for(i=0;i<data.length;i++){ for(j=0;j<data.length;j++){ if(data[i][j]=="gid")gid.push(data[i][j]) } } the console issues the following object
every nested object has a gid property. how do i get an array from this property?
gid=[] for(i=0;i<data.length;i++){ for(j=0;j<data.length;j++){ if(data[i][j]=="gid")gid.push(data[i][j]) } } data [i] [j] will be Undefined.
for(i=0;i<data.length;i++){ gid.push(data[i].gid); } length property is called only for data - GrundyFrom an object nested in an object that is in an array, you can:
for (var i = 0; i < data.length; i++){ for(var arg in data[i]){ if(arg === 'gid'){ // какие-то действия; } } } I apologize wildly about jquery not searching ... The answer is pure JS ...
Source: https://ru.stackoverflow.com/questions/530258/
All Articles