1. class Hexo{
    2. }
    3. /**
    4. * 代理构造函数
    5. * 函数本质就是对象
    6. */
    7. function constructorProxy(_class , ...propNames){
    8. return new Proxy(_class,{
    9. construct(target,argumentsList){
    10. const obj = Reflect.construct(target,argumentsList,)
    11. propNames.forEach((name,index) =>{
    12. obj[name] = argumentsList[index]
    13. })
    14. return obj;
    15. }
    16. })
    17. }
    18. const hexoPtoxy = constructorProxy(Hexo,'name','age','attack','defence','hp','rate')
    19. const hexo = new hexoPtoxy('张三','10','100','200','90','0.5')
    20. console.log(hexo)