DEV Community

Discussion on: Order of arguments in HOF

Collapse
 
leob profile image
leob • Edited

TBH this is what I would intuitively expect: first specify what you operate on (the data), then specify what you want to do. It would annoy me if it was the other way around!

To look at it from another angle: if the syntax is not "lodash like" as in your code sample but object oriented as in ES6 then it would be like this (using an arrow function):

[4,8].map((n) => n * n);

So in this syntax the data (object) obviously goes at the front, but if you change this to lodash syntax then it translates naturally to specifying the data as the first parameter. More readable IMO than the other way around.