function User(name){ this.name=name; } function createByObject(obj,...args){ const constructor= Object.getPrototypeOf(obj).constructor; return new constructor(...args); } let hd=new User('HDR'); let xj=createByObject(hd,'xj'); xj.show();
2023-10-19 12:41:52
function User(name){ this.name=name; } function createByObject(obj,...args){ const constructor= Object.getPrototypeOf(obj).constructor; return new constructor(...args); } let hd=new User('HDR'); let xj=createByObject(hd,'xj'); xj.show();