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

197
Views
Cómo agrupar una matriz de objetos por valores

Así que estoy tratando de agrupar un dato por el valor de la clave de categoría. La matriz se ve así. Tenga en cuenta que la categoría puede ser nula.

 const attributes = [ { category: "foo", x: "1", y: "2" }, { category: "foo", x: "3", y: "4" }, { category: "bar", x: "23", y: "4" }, { category: null, x: "2", y: "7" } ]

¿Cómo puedo agruparlo para que el resultado se vea así:

 const attributesByCategory = [ { category: "foo", attributes: [ { category: "foo", x: "1", y: "2" }, { category: "foo", x: "3", y: "4" } ] }, { category: "bar", attributes: [ { category: "bar", x: "23", y: "4" } ] }, { category: null, attributes: [ { category: null, x: "2", y: "7" } ] } ]

¿Qué función usaría o cómo la abordaría?

about 4 years ago · Juan Pablo Isaza
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!