Create a private namespace independent of other javascript - Javascript Object

Javascript examples for Object:Private Member

Description

Create a private namespace independent of other javascript

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  .  j  a  v a2 s.  com
x = function(){ 
  console.log('too late!'); 
};

(function(){
    x = function(){ console.log('hi!'); }
    x();
})();
    }

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

Related Tutorials