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

184
Views
Cómo crear un nuevo objeto a partir de uno anterior con valores filtrados

tengo un objeto:

 const items = { a: [3,5], b: [6,7,8], c: [0,10,1111] }

y la matriz:

 const existing = [3,8]

Me gustaría crear un nuevo objeto, pero sin valores que estén incluidos en la matriz existente. Me refiero a este:

 const newItems = { a: [5], b: [6,7], c: [0,10,1111] }

Por favor acerca de los consejos!

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

0

 const items = { a: [3,5], b: [6,7,8], c: [0,10,1111] } const existing = [3,8] const result = Object.keys(items).reduce((acc, key ) => { acc[key] = items[key].filter((item)=> !existing.includes(item)) return acc; }, {}) console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

Puede usar Object.entries y Object.fromEntries junto con el filter para obtener el resultado requerido.

 const items = { a: [3, 5], b: [6, 7, 8], c: [0, 10, 1111], } const existing = [3, 8] const newEntries = Object.entries(items).map(([key, value]) => [ key, value.filter((x) => !existing.includes(x)) ]) const newObject = Object.fromEntries(newEntries)
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!