|
|
|
|
|
by vanderZwan
1773 days ago
|
|
> list.reduce((x,y)=>Math.max(x,y)) Honestly, while I like the clarity, I would still dislike it in JavaScript for performance reasons, because in JavaScript reduce is not optimized at all. And yes, I do work on a code-base where that difference is significant. Also, that loop can still be cleaned up a bit in modern JS: let max = list[0];
for (const v of list) {
if (v > max) max = v;
}
|
|