Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. function mybase() {
  2. var that = {};
  3. var c = 0;
  4.  
  5. that.hi = function() {
  6. var ele = $('<div></div>');
  7. ele.html(c++);
  8. $('body').append(ele);
  9. }
  10.  
  11. return that;
  12. }
  13.  
  14. function myextended() {
  15. var that = mybase();
  16.  
  17. that.hi();
  18.  
  19. return that;
  20. }
  21.  
  22. myextended.prototype = new mybase();
  23.  
  24. $(document).ready(function() {
  25. var a = myextended();
  26. var b = myextended();
  27. })​
  28.  
  29. function myextended() {
  30. mybase.call(this); // apply the parent's constructor on the new object
  31. this.hi();
  32. }
  33.  
  34. myextended.prototype = Object.create(mybase.prototype);
  35.  
  36. function mybase() {
  37.  
  38. this.hi = function() {
  39. var ele = $('<div></div>');
  40. ele.html(this.c++);
  41. $('body').append(ele);
  42. }
  43. }
  44.  
  45. mybase.prototype.c = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement