Implement Object as JavaScript inherit object as property - Javascript Object

Javascript examples for Object:Object Property

Description

Implement Object as JavaScript inherit object as property

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  ww.  ja v a2 s  .c o m
var a = (function(){
    this.value = {
        val : "a"
    }
});
var b = (function(){
    a.call(this);
    this.value.val = "b";
    console.log("object b: " + this.value.val);
});
var c = (function(){
    a.call(this);
    console.log("object c: " + this.value.val);
});
var ObjectB = new b();
var ObjectC = new c();
    }

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

Related Tutorials