There are several ways to reach the same end point in JS, for example:
(function (foo, bar) {
return {run: function () {return foo(bar);}};
} (foo, bar));
(function (foo, bar) {
return (function(foo, bar) { return {run: function () { return foo(bar); }}} (foo, bar))
} (foo, bar))
(function (foo, bar) {
var Fizz = function (foo, bar) { this.run = function () { return foo(bar); }; };
return new Fizz(foo, bar)
} (foo, bar))
Now for these, I know that one difference is that the prototype in the third case for the returned object would be different, but other than that, all three paths lead to an object which provides the same api. And since Javascript is a duct typed language, what a thing is is usually defined by its behavior.
Are there any other implications of choosing any one approach of the three that I am ignoring ?