I have a class written on a project I'm working on that I've been told is using the module pattern, but it's doing things a little differently than the examples I've seen. It basically takes this form:
(function ($, document, window, undefined) {
var module = {
foo : bar,
aMethod : function (arg) {
className.bMethod(arg);
},
bMethod : function (arg) {
console.log('spoons');
}
};
window.ajaxTable = ajaxTable;
})(jQuery, document, window);
I get what's going on here.
But I'm not sure how this relates to most of the definitions I've seen of the module (or revealing?) module pattern. like this one from briancray
var module = (function () {
// private variables and functions
var foo = 'bar';
// constructor
var module = function () {
};
// prototype
module.prototype = {
constructor: module,
something: function () {
}
};
// return module
return module;
})();
var my_module = new module();
Is the first example basically like the second except everything is in the constructor? I'm just wrapping my head around patterns and the little things at the beginnings and endings always make me not sure what I should be doing.