/*
单例改造
1.需要instance 保存下来
*/
const singleTon=(function(){
function Person(name,age,sex){
this.name = name;
this.age = age;
this.sex = sex;
}
Person.prototype.say = function(){
console.log('hello')
}
let instance = null;
return function singleTon(...age){
if(!instance) instance = new Person(...age)
return instance
}
})()
const p1 = singleTon('熊明',18,'男')
const p2 = new singleTon('徐奥话',20,'女')
console.log(p1,p2)
console.log(p1==p2)