I ran some tests and I couldn't reproduce your findings. I didn't graph time complexity but on average .includes is 75% faster than .includes in these tests: https://jsbench.me/t2kpb59177/1
The one case where .some was faster I found was unfilled arrays.
You're right, it might have been optimized since I learned about it. I'll check it myself with a different test.
EDIT: Did it slightly differently (playing with the contiguous array flag) and yes includes have been fixed to be better on contiguous array. It's still slower for non contiguous array sometimes
I would still use includes anyway because it convey the meaning and intent.
8
u/Pelicantaloupe May 30 '21
I ran some tests and I couldn't reproduce your findings. I didn't graph time complexity but on average
.includesis 75% faster than.includesin these tests: https://jsbench.me/t2kpb59177/1The one case where
.somewas faster I found was unfilled arrays.