Assuming there is an arbitrary number of siblings from node, and I wanted to select nth sibling
this node, should I use .next()
chained n times, or should I just use one call .nextAll(':eq(n-1)')
?
It would seem that there would be a lot of extra overhead with the former for large n and possibly large overhead with the latter for a large number of siblings. I'm interested in a case that includes n = 2 and a large number of siblings, so I'm not sure if I want to use .next().next()
or .nextAll(':eq(1)')
. Does it matter?
Edit: for the case of n = 2 and many siblings, this looks like .next().next()
faster than http://jsperf.com/next-next-vs-nextall-eq-1-vs-nextall- eq-1
source share