Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. var module = (function (window, document, $) {
  2. // private variables and functions
  3. var _private = 'bar';
  4.  
  5. // constructor
  6. var module = function () {
  7. console.log('init module');
  8. };
  9.  
  10. // prototype
  11. module.prototype = {
  12. constructor: module,
  13. something: function () {
  14. console.log(_private);
  15. }
  16. };
  17.  
  18. // return module
  19. return module;
  20. })(window, document, jQuery);
  21.  
  22.  
  23. // Extensible:
  24. var module = (function (module) {
  25. module.prototype.something_else = function () {
  26. // content
  27. };
  28. return module;
  29. })(module);
  30.  
  31.  
  32. // USAGE:
  33. var my_module = new module();
  34. my_module.something();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement