function Resource(){ if(Resource.instance){ return Resource.instance }else{ this.balance = 100 Resource.instance = this } console.log(this,'this') } var r1 = new Resource() r1.balance = 50 console.log(r1) var r2 = new Resource() console.log(r2) //唯一实例外部改变同时改变