Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. var counter = function( start ) {
  12. this.count = start;
  13.  
  14. this.add = function() {
  15. this.count++;
  16. };
  17.  
  18. this.display = function() {
  19. console.log( this.count );
  20. };
  21. }
  22.  
  23. var a = new counter( 2 );
  24. var b = new counter( 11 );
  25. a.display();
  26. b.display();
  27. a.add();
  28. a.add();
  29. a.display();
  30. b.display();
  31. </script>
  32.  
  33.  
  34.  
  35. <script id="jsbin-source-javascript" type="text/javascript">var counter = function( start ) {
  36. this.count = start;
  37.  
  38. this.add = function() {
  39. this.count++;
  40. };
  41.  
  42. this.display = function() {
  43. console.log( this.count );
  44. };
  45. }
  46.  
  47. var a = new counter( 2 );
  48. var b = new counter( 11 );
  49. a.display();
  50. b.display();
  51. a.add();
  52. a.add();
  53. a.display();
  54. b.display();</script></body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement