In the Eloquent Javascript book I came across this code. I understood how this works and the passing of arguments but what I am unable to understand is author's statement regarding this code that it's a function which can create another function!
My question is: How is it creating a new function? What is happening which the author is calling creation of a new function? I mean sure we are creating a function called greaterThan and it has another function in it but I can't see how greaterThan is creating another function!
I assure you I have read many similar Qs before asking but couldn't find the answer I am looking for. Thank you for your time & help.
function greaterThan(n) {
return function(m) {
return m > n;
};
}
var greaterThan10 = greaterThan(10);
console.log(greaterThan10(11));
// → true