SOURCE

function A(name){
    // 如果已存在对应的实例
   if(typeof A.instance === 'object'){
       return A.instance
   }
   //否则正常创建实例
   this.name = name
    
   // 缓存
   A.instance = this
   return this
}

var a1 = new A()
var a2= new A()
console.log(a1 === a2)
console 命令行工具 X clear

                    
>
console