I have retrieved an array containing 2400 objects from our server, totaling about 7MB in size, and I need to extract specific values from it. Currently, I am using a combination of the filter
and slice
methods:
const keyword = 'whatever word';
const recommendList = bigArray.filter(item => item.name.includes(keyword)).slice(0, 5);
I understand that the filter
method iterates through all elements in the array which may impact the performance of my app (React Native) due to the large data set. Is there an alternative approach to filter the array for certain values without iterating through all elements?