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

198
Views
¿Cómo obtener claves particulares de un objeto?

tengo un objeto:

 a = { "1": "abc", "2": "def", "3": "ghi", "4": "jkl" }

y una matriz: b = ['abc','ghi'] Quiero obtener claves de los objetos cuyos valores están en una matriz y colocarlos en otra matriz, por lo que el resultado esperado es: ['1', '3'] .

No tengo idea de cómo filtrar las propiedades de los objetos. Intenté mapear una matriz y obtener valores, pero no estoy definido.

 const result = b.map(v => a[v])
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Podría usar Object.keys(a).filter(...) , y solo devolver verdadero si a[key] está en la matriz b .

about 4 years ago · Juan Pablo Isaza Report

0

Use filter() en Object.keys() :

 const a = {"1": "abc", "2": "def", "3": "ghi", "4": "jkl"}; const b = ['abc','ghi'] const c = Object.keys(a).filter(k => b.includes(a[k])); console.log(c);

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!