传入一个对象,利用Proxy包装返回一个单例对象 因为使用了Proxy,所以this绑定还是原来的对象不会受影响
const singleDate = singletonProxy(Date) const date1 = new singleDate() const date2 = new singleDate() date1 === date2 Copy
const singleDate = singletonProxy(Date) const date1 = new singleDate() const date2 = new singleDate() date1 === date2
传入一个对象,利用Proxy包装返回一个单例对象 因为使用了Proxy,所以this绑定还是原来的对象不会受影响