Assign value to prototype - Javascript Object

Javascript examples for Object:prototype

Description

Assign value to prototype

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  ww .  j  a v a 2  s . c  om*/
    function class1(){
        this.x5 = 5;
        this.x6 = 6;
        this.prototype = 123;
    }
    function class2(){
        this.x3 = 3;
        this.x4 = 4;
    }
    var obj1 = new class2();
    class2.prototype = new class1();
    console.log(obj1.x5 );
    });

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

Related Tutorials