Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- function counter( start ) {
- this.count = start;
- this.increase = function() {
- return this.count++;
- }
- this.decrease = function() {
- return this.count--;
- }
- this.display = function() {
- console.log( this.count );
- }
- }
- var a = new counter( 0 );
- var b = new counter( 2 );
- var c = new counter( 12 );
- a.increase();
- a.increase();
- a.increase();
- a.display();
- b.decrease();
- b.decrease();
- b.decrease();
- b.display();
- c.increase();
- c.display();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement