Skip to content

Commit 48e9c61

Browse files
committed
constructor-function
1 parent b588049 commit 48e9c61

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

functions/constructor-function.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function Counter() {
2+
var count = 0;
3+
4+
this.incrementCounter = function () {
5+
count++;
6+
console.log(count);
7+
};
8+
this.decrementCounter = function () {
9+
count--;
10+
console.log(count);
11+
};
12+
}
13+
var counter1 = new Counter();
14+
counter1.incrementCounter();
15+
counter1.incrementCounter();
16+
counter1.incrementCounter();
17+
counter1.decrementCounter();

0 commit comments

Comments
 (0)