Javascript examples for Object:Private Member
Add private members to a function
<!--// w ww . j a v a2 s . c o m Created using JS Bin http://jsbin.com Released under the MIT license: http://jsbin.mit-license.org --> <html> <head></head> <body> <script> var obj = (function() { var a = 0; return { run: function () { var q = a; a += 1; return q; } }; })(); console.log(obj.run()); console.log(obj.run()); </script> </body> </html>