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

163
Views
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
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!