Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 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. <script id="jsbin-javascript">
  10. function counter( start ) {
  11. this.count = start;
  12.  
  13. this.increase = function() {
  14. return this.count++;
  15. }
  16.  
  17. this.decrease = function() {
  18. return this.count--;
  19. }
  20.  
  21. this.display = function() {
  22. console.log( this.count );
  23. }
  24. }
  25.  
  26.  
  27. var a = new counter( 0 );
  28. var b = new counter( 2 );
  29. var c = new counter( 12 );
  30. a.increase();
  31. a.increase();
  32. a.increase();
  33. a.display();
  34.  
  35. b.decrease();
  36. b.decrease();
  37. b.decrease();
  38. b.display();
  39.  
  40. c.increase();
  41. c.display();
  42. </script>
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement