You should know that, in JavaScript programming language, functions are first class citizen. This means that a function can be stored in a variable, array, or object. Also, a function can be passed to and returned from a function. And the last one behavior is what is happening here. You got a function when you call the greaterThan() function. A normal behavior here in JavaScript Codes.
See what happens if run this code:
alert(objectA instanceof Function);
For better understanding see the next code:
function greaterThan(x) {
var result = function(y) {
return y > x;
};
return result;
}
What you get when you call the greaterThan function is just another function.
Another interesting matter in this code is related with how this new function maintains saved the value of x. This concept is called closures and you will see more here How do JavaScript closures work?.