Javascript examples for Function:Closure
Understanding of closure with function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w . jav a 2 s . co m function testClosure(){ var x = 2; return function(y){ console.log(eval(y)); } } var closure = testClosure(); closure("x+2"); } </script> </head> <body> </body> </html>