function Resource() { // 若是不是第一次new(instance確定是存在的) if (Resource.instance) return Resource.instance; else { // 不然(instance不存在) // 組裝新對象 this.balance = 100; // 將其存到Resource機器上 Resource.instance = this; } } var r = new Resource(); console.log('r:', r) r.balance = 50; console.log('r:', r) var r2 = new Resource(); console.log('r2:', r2); r.balance = 55; console.log('r2:', r2);