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

164
Vistas
Object construction from a keys array and values array without the use of loops

This question is extremely similar to:
generate object from key array and values array
Transform array of keys and array of values into array of objects javascript

This question has been answered more than once and might seem like a duplicate. It is possible to construct an object from arrays of keys and values. However, every method for such a construction uses loops or function like .reduce() that utilize loops. Deconstructing an object is can be easily done using inbuilt methods Object.keys() and Object.values() and Object.entries(). Constructing an object from key-value pairs is also possible using Object.fromEntries(). The issue is that given two arrays, one of keys and another of values, is it possible without loops to construct an object.

(Hopefully the sample code below clarify what my complicated question doesn't. PR might not be my strong suit ¯\_(ツ)_/¯)

function constructObject (keys, values)
{
  // ... loopless implementation
}

constructObject(["a", "b", "c", Symbol("d")], [0, null, false, {}]);
/*
// expected output
{
"a" : 0,
"b" : null,
"c" : false,
[Symbol("d")] : {}
}
*/
about 4 years ago · Santiago Trujillo
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