Are you sure? In the example you posted, the function returned from the
babyAnimals function takes an argument (
b) that is passed in later on when the returned function is called. This makes currying possible.
In the OP's example, the anonymous function being returned doesn't take any arguments, meaning that partial application is not possible. Instead, I would have said this is a higher-order function. One advantage to this approach is that the returned function would have access to any variables declared within
getB()'s scope (via closure), which would not be available from elsewhere in the code.
Please correct me if I'm wrong, as functions returning functions returning functions quickly starts to blow my mind.