Sitemap

Don’t use filter method on Large Datasets!

Mar 17, 2023

I was working on the application in which I faced a performance issue, the issue was related to the fact that I used a grid in Angular application and on the grid I was triggering a click event on the td element of the table.

In the method attached to that td I was passing the index of the row and on the .ts file I used .filter method of array, later I realized that if the array size reaches to 5000 records then this will hit a performance bottleneck.

So I decided to use the for loop instead of filter and it boosted my performance to the level I can’t imagine. Here’s the code for your reference:

Press enter or click to view image in full size

--

--

Emad Khan
Emad Khan

Written by Emad Khan

A Cutting-Edge & Modern Tech Evangelist

No responses yet