class Hexo{
}
/**
* 代理构造函数
* 函数本质就是对象
*/
function constructorProxy(_class , ...propNames){
return new Proxy(_class,{
construct(target,argumentsList){
const obj = Reflect.construct(target,argumentsList,)
propNames.forEach((name,index) =>{
obj[name] = argumentsList[index]
})
return obj;
}
})
}
const hexoPtoxy = constructorProxy(Hexo,'name','age','attack','defence','hp','rate')
const hexo = new hexoPtoxy('张三','10','100','200','90','0.5')
console.log(hexo)