DEV Community

loading...

Discussion on: 🔥 Getting the largest number from an array

oliverradini profile image
OliverRadini

Ah I see your point now, sorry I misunderstood what you were saying originally, my bad.

It is frustrating, but really we're talking about edge cases here where you're looking to pass variadic functions into Array.reduce. In this instance we're hitting a problem due to the fact that, firstly, Math.max is variadic and secondly that Array.reduce passes additional arguments by default. Agreed that neither of those is ideal.

JS really isn't a language of ideals, though - it's a pragmatic scripting language, and, for all its flaws, it allows people to get things done quickly. For me a big part of being a good JS programmer is learning to live with its flaws, because if you obsess over them, you can't get very far with it.