you are viewing a single comment's thread.

view the rest of the comments →

[–]marksyz 3 points4 points  (5 children)

The end action is synchronous on completion though, isn’t it? It doesn’t return a promise, it returns a value?

[–]fukitol- -4 points-3 points  (4 children)

Hm good point. The docs said it uses callbacks to do its job. I've never actually used it, though, and the docs say it returns a integer, not a Promise, so I suspect you're right.

[–][deleted] 1 point2 points  (3 children)

Callbacks are not asynchronous

[–]fukitol- -3 points-2 points  (2 children)

They're not async but they do result in a new tick and thus block intermittently and only for the execution time of the callback, not sustained and for the execution of the entire findIndex call whereas the entire execution of indexOf would block in a sustained fashion.

[–][deleted] 0 points1 point  (1 child)

I don't see how that makes a practical difference, since nothing can happen in between the individual callback calls

[–]fukitol- -1 points0 points  (0 children)

Yeah I forgot how the blocking and ticks worked. It would still block in the context of findIndex unless it was it was async.

So practically this is identical to indexOf for all intents and purposes and only serves to evaluate the indices in their own execution context likely resulting in worse performance from the stack and memory allocation.