Javascript examples for Object:Private Member
Create Public/Private function structure
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w . j a v a2 s . co m*/ function sumOfPrevious(n){ return (function privateFunc(n){ if (n == 1) return 1; else return n + privateFunc(n - 1); })(n); } console.log(sumOfPrevious(9)); } </script> </head> <body> </body> </html>