You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by dodieboy August 22, 2021
Hey, I will like to suggest to use includes() instate of indexOf() in your code when you are checking if the item exist. include() will be better in that case as you do not use the return int value of indexOf(), all you want is true or false which is what include() return.
Since it return true or false, equal operator is not needed (improve performance) and it is a Boolean (1 bit) which use lesser memory compare to int which is 16 bit.
Discussed in #2
Originally posted by dodieboy August 22, 2021
Hey, I will like to suggest to use includes() instate of indexOf() in your code when you are checking if the item exist. include() will be better in that case as you do not use the return int value of indexOf(), all you want is true or false which is what include() return.
Since it return true or false, equal operator is not needed (improve performance) and it is a Boolean (1 bit) which use lesser memory compare to int which is 16 bit.
Here is a performance test that I did: https://www.measurethat.net/Benchmarks/ShowResult/215464
The text was updated successfully, but these errors were encountered: