DEV Community

Discussion on: JS Performance: Perhaps We Shouldn't Always Use Arrays

Collapse
 
pchinery profile image
Philip

Thanks for this nice-to-read article and +1 for adding 100% accurate cat samples! There is just one performance problem: If your cats look too similar, you might have to look at more than one (which goes for cats in the house as well as in maps)

Collapse
 
nimmo profile image
Nimmo

Cat examples are the future I expect. :D

And yes, absolutely - this post was really meant just to say "maybe don't always use arrays", and offer an alternative in a specific example (i.e. searching for Marmalade in an array of 10,000 cats). And the reason for this was more because I am guilty of over-using arrays when other data structures are more appropriate!

Unless I've misunderstood your comment, in which case please feel free to expand if you think there's something more kind of...fundamentally wrong with this post - part of the reason for posting it was to get feedback from other people to be honest!

Collapse
 
pchinery profile image
Philip

Basically, I probably failed in making a pun 😉 My two cats look very similar and I sometimes have to look twice to tell them apart. And as maps usually use hashing, two hashes can be the same and you'd have to compare two cats (or more) to find the correct one, but that's a rather rare case, when not happening in my garden 😉