Posted By

twoism on 04/30/08


Tagged

javascript object method accessor


Versions (?)

Javascript: Private object with a public accessor


 / Published in: JavaScript
 

  1. if (typeof MyApp !== 'object') (function () {
  2. // Public Methods
  3. window.doPrivateMethod = function (boo) {
  4. MyApp.privateMethod(boo);
  5. }
  6. // Private Vars
  7. var MyApp = {
  8. init:function() {
  9. console.log(this);
  10. },
  11. privateMethod:function(res) {
  12. console.log('Called Private Method with ' + res);
  13. }
  14. };
  15. return MyApp.init();
  16. })();

Report this snippet  

You need to login to post a comment.