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

319
Views
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 answers
Answer question

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 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!