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

113
Vistas
Modified array of object with value from a given object TS/JS

Guys what is the best approach to modified array of object with value from object. E.g: lets say that we have array and object like this:

let arr = [
{
        parameter: 'aaa', 
        isSomething: false
},
{
        parameter: 'bbb', 
        isSomething: false
}, 
{
        parameter: 'ccc', 
        isSomething: false
}
];

let obj = {aaa: false, bbb: true, ccc: true}

and output that I want to achieve is:

let arr = [
{
        parameter: 'aaa', 
        isSomething: false
},
{
        parameter: 'bbb', 
        isSomething: true
}, 
{
        parameter: 'ccc', 
        isSomething: true
}
];

Could you help me with this one? I would be grateful. Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use Arra#map() combined with Destructuring assignment

Code:

const arr = [{parameter: 'aaa',isSomething: false},{parameter: 'bbb',isSomething: false},{parameter: 'ccc',isSomething: false}]

const obj = {
  aaa: false,
  bbb: true,
  ccc: true
}

const result = arr.map(({ parameter, isSomething }) => ({ 
  parameter, 
  isSomething: obj[parameter]
}))

console.log(result)

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