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">
- var counter = function( start ) {
- this.count = start;
- this.add = function() {
- this.count++;
- };
- this.display = function() {
- console.log( this.count );
- };
- }
- var a = new counter( 2 );
- var b = new counter( 11 );
- a.display();
- b.display();
- a.add();
- a.add();
- a.display();
- b.display();
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">var counter = function( start ) {
- this.count = start;
- this.add = function() {
- this.count++;
- };
- this.display = function() {
- console.log( this.count );
- };
- }
- var a = new counter( 2 );
- var b = new counter( 11 );
- a.display();
- b.display();
- a.add();
- a.add();
- a.display();
- b.display();</script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement