Javascript examples for Object:Private Member
Create function to return a function, sharing private data
<html> <head></head> <body> <script> var testFn = function(testVal) { var test = testVal;//from w ww . j ava 2s . c o m return { getVal: function() { return test; } } }; var ab = testFn (4); var ac = testFn (2); console.log(ab.getVal(),ac.getVal()) </script> </body> </html>