Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
how can i extract a result from array in javaScript?
window.onload = function() {
    $.ajax({
        url : "/auctionCount.kh",
        data:{memberNo:memberNo},
        success : function(list){
            for(let i=0;i<list.length;i++){
                console.log(list[i]);
            }
        }
    });
};

enter image description here

I got it as a hashmap type in sql.

I need to extract divno, prevcount, projectname, projectno, viewdif, viewcount separately here but I don't know how

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

if you like one liner you can do it like this

let data = [{DIVNO: 4, PREVCOUNT: 5, PROJECTNAME: 'xx', PROJECTNO: 21, VIEWCOUNT: 0, VIEWDIF: 0}, {DIVNO: 5, PREVCOUNT: 6, PROJECTNAME: 'xx2', PROJECTNO: 22, VIEWCOUNT: 1, VIEWDIF: 1}];


const result = data.reduce((res, item) => Object.fromEntries(
  Object.entries(item).map(([k, v]) => [k, [...(res[k] || []), v]])
), {})

console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

If you simply wish to access them, you'd just use the dot operator:

console.log(list[i].DIVNO);
console.log(list[i].VIEWDIF);
// etc..

If you want to access the objects key-value pairs, regardless of what they are:

for (const [key, value] of Object.entries(list[i])) {
    console.log(`${key}: ${value}`);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!