I'm reading Eloquent Javascript to get a Javascript base. I was understanding well, since the fundamental does not change in relation to other languages, like data types (int, string, bool, objects, arrays). But I came to the Abstraction section. I know that this is also part of the other languages, being one of the bases for many design patterns there,
But I did not understand the concept of High Order Functions .
Let's see the example shown in Eloquent Javascript p. 90:
Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions.
(Functions that operate on other functions, either by taking them as arguments or by returning them, are called high-order functions.)
function greaterThan ( n ) {
return function ( m ) { return m > n; };
}
var greaterThan10 = greaterThan (10) ;
console . log ( greaterThan10 (11) ) ;
// → true
What I did not understand, especially, was this example there. Mostly part of the arguments.
First it sets greaterThan10 = greaterThan10(10)
, and passes argument 10 to this function , and hence it can call VARIAVEL as function ? And the arguments? Will the first argument passed in the definition continue there? (10)
I'm a bit confused, I'd like a slightly simpler explanation, or an example where this concept is more visible.