Sometimes a simple line of JavaScript can do more work than you expect.
For example, array.includes() is fine for small arrays, but using it again and again with large datasets can affect performance. Things get even more interesting when it is used inside another loop.
I recently wrote about this with simple JavaScript and React examples, including when using Set or Map can be a better choice.
👉 Read the full article: https://nirmitkotadiya.dev/dsa/big-o-javascript-array-includes
You don't need to optimize everything. The important part is knowing where a small change in your data structure can make your code much more efficient.
Top comments (0)