Modular Javascript

In this example below you will see how to do a Modular Javascript with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by 0_7734, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 0_7734 ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Modular Javascript</title>
  
  
  
  
  
</head>

<body>

  
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/0_7734/modular-javascript-YNgVvG */
var Module = (function () {

  var privateMethod = function () {
    // private
    alert('world');
  };

  var someMethod = function () {
    // public
    alert('hello');
    privateMethod();
  };
  
  return {
    someMethod: someMethod
  };

})();

Module.someMethod();

Comments