1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| var A; (function(name){ var instance; A = function(name){ if(instance){ return instance } instance = this this.name = name } }()); A.prototype.pro1 = "from protptype1" var a1 = new A('a1') A.prototype.pro2 = "from protptype2" var a2 = new A('a2') console.log(a1.name) console.log(a1.pro1) console.log(a1.pro2) console.log(a2.pro1) console.log(a2.pro2)
|