prototype class creation


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.