This code is from the AngularJS source code, which has alot of this 'function returning a function' style code.
function locationGetterSetter(property, preprocess) {
return function(value) {
if (isUndefined(value))
return this[property];
this[property] = preprocess(value);
this.$$compose();
return this;
};
}
What advatanges does this have over just having a 'regular' function with extra parameters such as this -
function locationGetterSetter(property, preprocess, value) {
if (isUndefined(value))
return this[property];
this[property] = preprocess(value);
this.$$compose();
return this;
}