自定义函数创建对象
作者:互联网
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();
标签:xj,function,obj,name,自定义,...,创建对象,constructor,函数 来源: https://www.cnblogs.com/yyy1234/p/15852653.html