var function (ARG) { // function body };
Anonymous function: Creates a function and assigns it to a variable, in which case the function created is called an anonymous function because there is no identifier behind the function keyword. (anonymous functions are sometimes called lambda functions). The Name property of the anonymous function is an empty string.
Note: FireFox, Safari, Chrome, and opera all define a nonstandard Name property for the function, which gives you access to the name specified by the function. The value of this property always equals the identifier followed by the function keyword.
Closures are functions that have access to variables in another function scope. A common way to create closures is to create another function inside the function.
functioncomparison (PropertyName) {return function(object1,object2) {varValue1 =Object1[propertyname]; varvalue2 =Object2[propertyname]; if(value1>value2) { return-1; }Else if(value1>value2) { return1; }Else{ return0; } }; }
JS closure, anonymous function concept