In a function (fenceBasic) taking an object as parameter and de-structuring it in order to pick only what is needed, can the (sub-)arguments be restructured as a literal object.
There is an arguments
object traditionally available , but it appears that it's an undefined one in the following fenceSpread function :
const next = (obj) => {
console.assert(obj.arg1 === 'A', obj);
console.assert(obj.arg2 === 'B', obj);
};
const fenceBasic = ({ arg1, arg2 }) => {
console.log('basic way');
next({ arg1, arg2 });
};
const fenceSpread = ({ arg1, arg2 }) => {
console.log('spread way');
next({...arguments});
console.debug(arguments);
};
const various_data = {
arg1: 'A',
arg2: 'B',
arg3: 'C'
};
fenceBasic(various_data);
fenceSpread(various_data);
Is there an other way to achieve this or should it stay on the "fenceBasic" form ?