More and more javascripthas this modular approach in which empty functions are returned. You can find it in the source node.js. This is in the documentation require.js. What is he doing?
define(['jquery'] , function ($) {
return function() {};
});
If I were returning an object, I would just do it return {};, although I see no reason to return an empty object. Could put vars in it. Therefore, there is something valuable in it. I assume this has something to do with accessing functions that were in the scope of the returned function.
Here is this design again, AMD's article does not answer :
define(['dep1', 'dep2'], function (dep1, dep2) {
return function () {};
});
But what is the practical benefit of the above, instead of just returning the semantically relevant material that you want to return, for example. in the facility?
?
function(baz) {
var foo = true,
bar = false;
if (baz) bar = true;
return function() {};
};
"", , - , .