
10 users in db and 2 online users const users = [ ) įinally, you are happy? :) Just like and share also subscribe to newsletter. We will compare the performance when using both Array.includes() and Set.has() to see the impact.

the users array which represents all users exist in the database and the sessions array which stores online users ids. This will address instances where the project also uses. In this example, we will get user’s information who are online. The types will tell the TypeScript compiler to only include type definitions from Cypress. So using Set.has() in your codebase has a great impact on the performance which enhances the performance. Array.includes() has a time complexity o(n).

I am sure after reading this article you will be happy :) from this article, you will learn how to optimize your code and increase performance by these examples.Īrray.includes and Set.has() both used for searching for a specific value within an array or set.
