Inspect a closure in Javascript or local variables - Javascript Function

Javascript examples for Function:Closure

Description

Inspect a closure in Javascript or local variables

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 ww  w.java2  s .c om
function MyClass(name){
  this.age = 0;
  this.started = false;
  this.start = function(){
    this.started = true;
  };
  this.forward = function(){
    this.age++;
  };
  console.log(this );
}
var my = new MyClass('boby');
my.start();
my.forward();
console.log(my);
    }

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

Related Tutorials