function F(name,age){this.name=name;this.age=age;}
var single=(function(){
var instance;
return function(){
if(instance) return instance;
var Constructor=[].shift.call(arguments)
instance=new Constructor(...arguments)
return instance
}
})()
var f1=single(F,'aaa',19)
var f2=single(F,'bbb',78)
console.log(f1,f2);
07-26
7773
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-24
2109
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)