The code
function learning(x,y) {
return function inLearning(z){
return console.log(x) + console.log(y) + console.log(z);
};
};
creates a function whose duty is to return on its turn a function that does something. In this case it prints the received parameters (or sent arguments). A call as learning(1, 2)(3) will show:
1
2
3
Try to experiment with different calls: learning(2)(3), learning(1, 2)(), learning(1,2,5)(3,4), learning()(5), etc.
It is a pattern that should help eliminating extra function executions, and avoid repetitions of code that ideally would then be easier to understand and maintain.
A good starting point to understand this kind of pattern is the JavaScript Functions that Return Functions post.