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

273
Views
array.incluye( () => {} ) como una función

¿Existe un método como include que solo busca un elemento en una matriz pero le permite ver los elementos que se están iterando?

por ejemplo: tengo la siguiente matriz:

 const arr = [{ color: 'red' },{ color: 'blue' },{ color: 'pink' },{ color: 'green' }]

Quiero verificar si el arr contiene un elemento con el valor de pink : así que pensé si hay algo como esto en JavaScript:

 arr.includes( (el, index)=> el.color == 'pink' )

que luego devuelve un valor booleano, ya sea verdadero o falso.

¿Hay un método como ese en JavaScript? si no, ¿qué pasa con lodash ?

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

0

Creo que quieres encontrar:

 if (arr.find(el => el.color === "pink")) console.log("it's there");
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!