DEV Community

[Comment from a deleted post]
Collapse
 
theodesp profile image
Theofanis Despoudis • Edited

Tip: You can re-write midpoint as const midpoint = arr.length >> 1

Collapse
 
_bigblind profile image
Frederik 👨‍💻➡️🌐 Creemers

While that might be faster, I think the original might be clearer.

Collapse
 
joelnet profile image
JavaScript Joel

I would agree. Software is written for humans, not computers. Although, interesting, this seems like a premature optimization.

Collapse
 
theodesp profile image
Theofanis Despoudis

Actually this way you avoid using Math.floor and it's not so bad. Its just a build-in operator