Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

321
Vistas
How to read the current object data when Javascript .some() returns true?

In my project I have an array, holding thousands of objects. I need to search for an explicit object inside the array. When the match is found, I need to be able to access the object properties. Because of performance I want to use Javascript's .some() function. But with the code I have so far I only get a 'true' as return. How can I access the properties inside when the if-statement is a hit?

My code:

let array = [
            {object.uid: 'one',
             object.value: 'Hello one'},
            {object.uid: 'two',
             object.value: 'Hello two'},
            {object.uid: 'three',
             object.value: 'Hello three'}]

if (array.some(e => e.uid == "two")){
   //how do I get object.value here?
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use find() method instead of some()

let array = [
            {uid: 'one',
             value: 'Hello one'},
            {uid: 'two',
             value: 'Hello two'},
            {uid: 'three',
             value: 'Hello three'}]
const obj = array.find(e => e.uid == "two");
if (obj){
   console.log(obj)
};

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda