Check this reference in child object - Javascript Object

Javascript examples for Object:Constructor

Description

Check this reference in child object

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 www.  j  a  v  a2  s  .c o  m*/
function Child() {
    this.method = function() {
         console.dir(this);
    };
}
function Parent() {
    this.child = new Child();
}
var p = new Parent();
p.child.method();
p.child.method.call(p);
    }

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

Related Tutorials