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

232
Views
¿Cómo obtener el valor de propiedad del objeto más repetido usando lodash?

Soy nuevo en lodash y me preguntaba cómo podría usarlo para obtener el valor de propiedad más repetido en una matriz de objetos. Como decir que tengo una matriz como

 var arr1 = [{points: 50, player: LeBron James},{points: 32, player: Kevin Durant},{points: 62, player: LeBron James},{points: 90, player: LeBron James}]

En la propiedad del jugador en arr1, "LeBron James" es el más repetido. ¿Cómo obtendría esto usando lodash? Gracias de nuevo.

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

0

Simplemente use _.uniqBy() Crea una versión sin duplicados de una matriz.

 var objects = [{points: 50, player: 'LeBron James'},{points: 32, player: 'Kevin Durant'},{points: 62, player: 'LeBron James'},{points: 90, player: 'LeBron James'}]; var result = _.head(_(objects) .countBy('player') .entries() .maxBy(_.last)); console.log(result);
 <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.19/lodash.min.js"></script>

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!