Daud Daud - 5 months ago 66
AngularJS Question

Which javascript construct is this AngularJS filter expression?

If we wish to use a filter in AngularJS on the controller side, we use this

$filter('filter')(array, expression, comparator, anyPropertyKey)


I can't understand which javascript construct is this using. I mean, its not a function, its not an assignment expression, its not a self-executing function. What is it ?

Answer

It's a function which returns a function which you then execute.

function foo() {
    return function bar() {};
}

foo()();

// equivalent to:
var b = foo();
b();
Comments