Classes objects prototype and static


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // class
  2. var myClass = function(param) {
  3. // private member
  4. var myMember = param;
  5. // private method
  6. var myMethod = function(whatever) {
  7.  
  8. };
  9.  
  10. //public member
  11. this.myPublic = 7;
  12. // public method
  13. this.myPublicMethod = function(whatelse) {
  14.  
  15. };
  16. };
  17.  
  18. // prototype (public)
  19. myClass.prototype.myNewMember = 7;
  20. myClass.prototype.myNewMethod = function() {};
  21.  
  22. // static
  23. myClass.myStatic = 8;
  24.  
  25. // object
  26. var myObject = new myClass(7);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.