Skip to content
Advertisement

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:

JavaScript

Advertisement

Answer

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

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement