Javascript examples for Function:Closure
Inspect a closure in Javascript or local variables
<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>