Posted By

arpo on 04/04/11


Tagged


Versions (?)

A basic "class" in JavaScript


 / Published in: JavaScript
 

  1. var WHATEVER = {};
  2.  
  3. WHATEVER.main = (function () {
  4.  
  5. var privateVar = "I can be accessed only from within WHATEVER.basic.",
  6. privateMethod;
  7.  
  8. privateMethod = function () {
  9. console.log("I can be accessed only from within WHATEVER.basic");
  10. };
  11.  
  12. return {
  13. publicProperty: "I'm accessible as WHATEVER.basic.publicProperty.",
  14. init: function () {
  15. console.log("I'm accessible as WHATEVER.basic.init.");
  16. privateMethod();
  17. }
  18. };
  19.  
  20. }());
  21.  
  22. WHATEVER.main.init();

Report this snippet  

You need to login to post a comment.