SOURCE

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)

//唯一实例外部改变同时改变
console 命令行工具 X clear

                    
>
console