SHOW:
|
|
- or go back to the newest paste.
1 | - | /*simulating php static keyword in javascript*/ |
1 | + | /*simulating php static keyword in javascript ( http://jsbin.com/xataqaqevini/1/edit )*/ |
2 | ||
3 | function User( name ) { | |
4 | this.name = name; | |
5 | this.__proto__.count++; | |
6 | //User.prototype.count++; | |
7 | //Object.getPrototypeOf(this).count++; | |
8 | } | |
9 | ||
10 | User.prototype.count = 0; | |
11 | ||
12 | var ali = new User('ali'); | |
13 | var abu = new User('abu'); | |
14 | var adi = new User('adi'); | |
15 | ||
16 | console.log(User.prototype.count); |