Posted By

arcturus on 12/02/07


Tagged

javascript prototype


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

korzhik
hans


prototype class creation


 / Published in: JavaScript
 

  1. //Use with prototype 1.6
  2. var Person = Class.create({
  3.  
  4. initialize: function(){
  5. //Create a Hash for information store
  6. this.info = $H();
  7. }
  8. ,
  9. setName: function(name){
  10. this.info.set("name",name);
  11. }
  12. ,
  13. getName: function(){
  14. return this.info.get("name");
  15. }
  16. ,
  17. setSurname: function(surname){
  18. this.info.set("surname",surname);
  19. }
  20. ,
  21. getSurname: function(){
  22. return this.info.get("surname");
  23. }
  24. ,
  25. toJSON: function(){
  26. return this.info.toJSON();
  27. }
  28. });

Report this snippet  

You need to login to post a comment.