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

127
Views
Cómo establecer el valor del objeto como clave para otro valor del objeto

datos actuales

 [ { "id": 0, "name": "Active", "value": "Y", z" }, { "id": 1, "name": "controls", "value": "N", } ]

datos de resultado

 {"Active":"Y", "controls":"N"}

cómo asignar el valor de un elemento en el objeto como otra clave de elemento (como un objeto)

about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

 x = [{ "id": 0, "name": "Active", "value": "Y", }, { "id": 1, "name": "controls", "value": "N", } ] a = x.reduce((a, b) => ({...a, [b.name]: b.value }), {}) console.log(a) s = x.map(item => ({ [item.name]: item.value })) console.log(s)

about 4 years ago · Santiago Gelvez Report

0

 const data = [ { "id": 0, "name": "Active", "value": "Y" }, { "id": 1, "name": "controls", "value": "N" }, ] const result = data.map(item => { return { [item.name]: item.value } }) console.log(result)

about 4 years ago · Santiago Gelvez Report

0

Creo que quieres esto:

 let elements = [ { "id": 0, "name": "Active", "value": "Y"}, { "id": 1, "name": "controls", "value": "N"}, ] let new_element = Object() elements.forEach(element=>{ new_element[element.name] = element.value }) console.log(new_element)
about 4 years ago · Santiago Gelvez 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!