Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

210
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda