DEV Community

Emad Hassan Khan
Emad Hassan Khan

Posted on

Don’t use filter method on Large Datasets!

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:

Code Snippet

Top comments (0)