Using modular pattern to create a module - Javascript Object

Javascript examples for Object:Module

Description

Using modular pattern to create a module

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from  w  w w.ja  v a  2 s .c  o  m
var module_pattern = (function() {
  var private = 'private';
  var a = function() { console.log('private variable is ' + private);};
  var b = function() {};
  return {a: a };
})();
module_pattern.a();


    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials