Recently, I stumbled upon a JavaScript file that was constructed in quite an unconventional way:
var modal = (function(){
var method = {};
// Function to center the modal in the viewport
method.center = function () {};
// Function to open the modal
method.open = function (settings) {};
// Function to close the modal
method.close = function () {};
return method;
}());
While I grasp the concept of encapsulating functions within the "modal" object, I can't help but wonder why all the functions are bound to method
and then returned at the end?