Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var module = (function (window, document, $) {
- // private variables and functions
- var _private = 'bar';
- // constructor
- var module = function () {
- console.log('init module');
- };
- // prototype
- module.prototype = {
- constructor: module,
- something: function () {
- console.log(_private);
- }
- };
- // return module
- return module;
- })(window, document, jQuery);
- // Extensible:
- var module = (function (module) {
- module.prototype.something_else = function () {
- // content
- };
- return module;
- })(module);
- // USAGE:
- var my_module = new module();
- my_module.something();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement