class SinglePerson { constructor(name,age) { this.name = name this.age = age } static instance = null; static getInstance(name,age){ if(SinglePerson.instance) return SinglePerson.instance return SinglePerson.instance = new SinglePerson(...arguments) } } let p1 = SinglePerson.getInstance("小明",18) let p2 = SinglePerson.getInstance("小绿",17) console.log(p1) console.log(p2)