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

220
Views
javascript eliminar objeto en blanco

tengo una matriz de objetos que se parece a: (valores ofuscados)

 [ { "title": "l", "data": [ { "id": "x", "bodyPart": "x", "equipment": "x", "gifUrl": "h", "name": "x", "target": "x", "broad_target": "x", "ppl": "p", "thumbnail": "h", "heatmap_target": "u" } ] }, {} ]

si te das cuenta, hay un {} en blanco.

mi intento de eliminar estos es:

 const cleanEmpty = obj => Object.entries(output) .map(([k,v])=>[k,v && typeof v === "object" ? cleanEmpty(v) : v]) .reduce((a,[k,v]) => (v == null ? a : (a[k]=v, a)), {});

esto no funciona.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

puede usar Array.filter para filtrar los objetos en blanco como este:

 const arr = [ { foo: "bar" }, {} ] const newArr = arr.filter(obj => Object.keys(obj).length >= 1) console.log(newArr) //[{foo: "bar"}]
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!