Can I use apply() with constructor to pass arbitrary number of parameters

前端 未结 4 548
天命终不由人
天命终不由人 2020-12-10 17:35

I\'ve got a function wich can accept a varible number of parameter with a rest operator.

I want create an object passing the argument collected with the rest opera

4条回答
  •  温柔的废话
    2020-12-10 18:00

    well there's also this

    public function myFunc(args:Object) {
    
       //then access various argumens
       return new MyClass(args.name, args.id, args.active)
    
    }
    

    and call it through myFunc({id:33,name:'jo')

    you could then pass the object, or is this too far from what you're looking for?

提交回复
热议问题