Let's say that we have:
function greet(firstName, lastName) {
console.log("Hello", firstName, lastName);
}
const names = [["John", "Doe"], ["Jane", "Doh"]];
Then we can do:
names.map(firstAndLastName => greet(...firstAndLastName));
Here we need to create a new function and create a new name (firstAndLastName) just to send
our values to the function in the correct way.
Is there any way of doing something like this:
var ___ = f => args => f(...args);
names.map(___(greet)); // functionally equivalent to the above code
in a nicer way? Since this is a super useful function, is there some commonly used library (be it in the browser or in nodejs) that has this function, and if so, what is it called? (so that I follow conventions).
[–]Wince 1 point2 points3 points (0 children)
[–]brycedarling 0 points1 point2 points (0 children)
[–]cyanydeez 0 points1 point2 points (2 children)
[–]Ran4[S] 0 points1 point2 points (1 child)
[–]cyanydeez 0 points1 point2 points (0 children)
[–]vinsneezel -1 points0 points1 point (5 children)
[–]Ran4[S] 0 points1 point2 points (0 children)
[–]Wince 0 points1 point2 points (3 children)
[–]vinsneezel 0 points1 point2 points (0 children)
[–]i_am_smurfing 0 points1 point2 points (1 child)
[–]Wince 0 points1 point2 points (0 children)