queryResultArr is the array that olds mysql queries results, let say i have in my table two columns: doc_1_hits and doc_2_hits, but i don't know prior how much docs i have and i want to run a loop like you can see below: queryResultsArr[0].doc_i_hits instead of doc_1_hits.
i tried a: var str = 'doc_'+i+'_hits'; and then queryResultsArr[0].str but nothing..
for(var i = 1; i < 3; i++){
if(queryResultsArr[0].doc_i_hits > 0 && queryResultsArr[1].doc_i_hits == 0){
console.log(i);
}
}
I think you could use the array notation and do it like below because they work similar in this case.
var a = 'doc_'+i+'_hits';
queryResultsArr[0][a]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments