One key thing missing in this is why to choose between the two. Sure, there’s a difference between splitting a 3-argument function into two versus three sub-functions, but so what?
The key to creating partial applications is partial applications can be useful on their own.
Two out of three curried parameters really doesn’t mean much without the third parametric function. But a partial application is useful either with the remaining parameters or on its own.
Take the following gist as an example. The objectsEqual()
function either takes the objects to compare and a testing map, or just the testing map. If it just takes the testing map, it returns a standalone function that compares two objects.
With this function, we can create an object tester to be used within the mapper for testing an object:
This is what makes partial application functions so useful beyond simple currying. Instead of simply collecting parameters, they permit you to parametrize your logic, creating different functions with similar but unique functionality.