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

95
Views
Transform Array of Objects to spesific Object structure Javascript

[
   {
      "Hari Libur":{
         "date":"12-07"
      }
   },
   {
      "Hari Libur":{
         "date":"12-12"
      }
   },
   {
      "Hari Libur":{
         "date":"12-04"
    }
]

Into this Object structure

{
    'Hari Libur': {date: '12/07'},
    'Hari Libur': {date: '12/12'},
    'Hari Libur': {date: '12/04'}
}

I have tried with Object.assign but it also include me with 0:{} , 1:{}, 2:{}.

Is there any other way to do ?

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

0

var arr =[
   {
      "Hari Libur":{
         "date":"12-07"
      }
   },
   {
      "Hari Libur1":{
         "date":"12-12"
      }
   },
];
var obj ={}
var res = arr.map(d=>{
  var key = Reflect.ownKeys(d);
  var date = d[key].date;
  obj[key[0]]={"date":date}
})
console.log(obj)
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!