I think the biggest question is how big n is? This is processing a list of pop-ups. If there's more than a couple there are probably bigger problems. 🤷 And O(n2) is pretty insignificant if n is 1.
True! It could be viewed as premature optimization to care about that - but it's worth noting that not using indexOf in this piece of code would likely make it more readable: this operation requires one iteration, and doing only one iteration makes it easiest for the reader to get the intention.
In the end, it's just one item on a list of reasons why this is inferior to the one-liner that should be there.
View all comments
Show parent comment
2
u/chinpokomon Feb 19 '22
I think the biggest question is how big n is? This is processing a list of pop-ups. If there's more than a couple there are probably bigger problems. 🤷 And O(n2) is pretty insignificant if n is 1.