Let's say there are two ways to define a function:
First way:
Bar.prototype.foo = function ()
{
// do something
}
Second way:
Bar.prototype.foo = function ()
{
return function () {
// do something
}
}
For sure the second way is useful in case of closure.
There are other case where the second way is preferable to the fist one?