Guest User

Untitled

a guest
May 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. // ES5 example
  2. var module = (function() {
  3. 'use strict';
  4.  
  5. var selectors = {
  6. // object literal would contain selectors
  7. mySelector: '.banner'
  8. };
  9.  
  10. var publicMethod = function() {
  11. console.log("I'm a public function you should see me in console, i can be called by typing module.publicMethod()");
  12. };
  13.  
  14. var privateMethod = function() {
  15. console.log("I'm a private function you should see me in console but cannot access me via a function");
  16. };
  17.  
  18. var init = function() {
  19. privateMethod();
  20. };
  21.  
  22. return {
  23. init: init,
  24. publicMethod: publicMethod
  25. };
  26. })();
  27.  
  28. module.init(); // I'm a private function you should see me in console but cannot access me via a function
  29. module.publicMethod() // I'm a public function you should see me in console, i can be called by typing module.publicMethod()
  30. module.privateMethod() // module.privateMethod is not a function
Add Comment
Please, Sign In to add comment