Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var myModule = (function() {
- // private attr
- var _priVar = 10;
- // private function
- var _priMethod = function() { return "foo"; }
- return {
- // public attr
- pubVar: 10,
- // private function
- pubMethod: function() { return "bar"; },
- // access to private method and variable
- getData: function() { return _priMethod() + _priVar}
- }
- })(); // get the anonymous function to execute and return
- MyModule.getData();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement