markdown guide
 

jsbench.me/g4jx2nffbo/1

Array.prototype.reduce() seems to be much faster.

array.reduce((acc, val) => val > acc ? val : acc);
 
console.time('first')
    Math.max(...array)
console.timeEnd('first') // first: 0.179ms

console.time('second')
    array.reduce((acc, val) => val > acc ? val : acc)
console.timeEnd('second') // second: 0.054ms

Definitively slower to execute but half the time to write it :)

 

Depends what the codes for really.

Math.max() is easier to read, and if only run occasionally on small arrays... fine.

Reduce is a little more convoluted, but still can be understood easily enough. The time savings on the code if running frequently or on larger datasets can quickly add up in benefits.

 
Classic DEV Post from Jul 26

🎩 JavaScript Enhanced Scss mixins! 🎩 concepts explained

Drozerah profile image
Software Developer actually interested in JavaScript Back-End

dev.to now has dark theme. 🌝

Go to the "misc" section of your settings and select night theme

P.S. It's also the best place to talk code amongst thoughtful developers, and it's totally open source.