DEV Community

Discussion on: Top 20 JavaScript tips and tricks to increase your Speed and Efficiency

Collapse
 
liquorburn profile image
liquorburn • Edited

I've made a simple benchmark, it seems that reduce() is faster than Math.max()

dev-to-uploads.s3.amazonaws.com/up...

Thread Thread
 
techygeeky profile image
Kapil Raghuwanshi🖥

That's awesome @liquorburn . I have added the fastest one only.

Thread Thread
 
tommus profile image
Thomas Smith • Edited

It's actually the spread operator that's taking the time there. Though admittedly, there aren't many cases you'd have a hardcoded list of values to find the max of, it's worth pointing out.

dev-to-uploads.s3.amazonaws.com/up...