Javascript examples for Function:Function Return
Nested Function returning
<html> <head> <meta name="viewport" content="width=device-width"> </head> <body> <script> function counter() {//from w ww . ja va 2 s.c o m var x = 0; function internal() { x++; return x; } internal.toString=function(){return internal().toString();}; return internal; }; console.log(counter()); var count=counter(); console.log(count); console.log(count); console.log(count); </script> </body> </html>