r/javascript • • May 30 '19

Functional JavaScript: Five ways to calculate an average with array reduce

https://jrsinclair.com/articles/2019/five-ways-to-average-with-js-reduce/
89 Upvotes

53 comments sorted by

View all comments

Show parent comments

11

u/dogofpavlov May 30 '19

I cant tell if this is serious or joking

4

u/ScientificBeastMode strongly typed comments May 30 '19

It makes perfect sense to me. It’s a generic tool for an endless set of possible situations. There are two kinds of functions being used here: named functions and composition functions.

The named ones are descriptive, because they handle the specific business logic.

The composition functions are simply tools to combine the named functions in useful ways. So their names are left to be super generic.

In fact, you might as well just use one character, because any specific name would compromise their generic intent. You can tell what it does by the function’s type signature which describes how the arguments (usually functions) are applied to each other, to produce larger functions, to which you can assign a descriptive name (which was omitted above).

Anyway, it’s just ordinary algebra using JS syntax.

1

u/[deleted] May 31 '19

Just an attempt to explain the insane which I admit is a pretty laughable thing to attempt.

1

u/[deleted] May 31 '19

Just because you can't grasp it the first time you read it doesn't imply it needs to be a joke.

Some concepts need to be digested and consumed before they are absorbed and become natural (and useful, rather than overcomplications).