Call method from class without instantiate it - Javascript Object

Javascript examples for Object:prototype

Description

Call method from class without instantiate it

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(){/*w w w  .  j av  a 2  s.com*/
 var SuperClass = function(){};
  SuperClass.prototype.init = function() {
      console.log("Init");
  };
SuperClass.prototype.init();
var sc = new SuperClass();
sc.init();
    }

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

Related Tutorials