Don't know if is possible with ES6. I'm working in a project that have a function which is passed an Object with lots of properties. Right now the code is as follows:
function foo({arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8}){
this.model = arg1;
this.model = arg2;
// and so on...
};
obj = {
arg1: 'some',
arg2: 'whatever',
arg3: 'text'
// and so on up to 8
arg8: 'end text'
}
foo(obj);
Mi DESIRED output would be,if possible, accessing the parameters like this:
function foo( {...args} ){ // not working
this.model = arg1;
this.model = arg2;
// and so on...
};
obj = {
arg1: 'some',
arg2: 'whatever',
arg3: 'text'
// and so on up to 8
arg8: 'end text'
}
foo(obj);
So question is: is there any way for the function to get parameter object in a single var (args) AND have them destructured to be ready to use?