Maybe a luxury problem, but Im searching for the most elegant way to pass a selection of object parameters to a function. This is what I'd like to achieve :
const allParameters = {
a: '1',
b: '2',
c: '3',
private_d: '4',
}
function executeWithHiddenParameters(callback){
return callback( {a,b,c} = allParameters );
}
Currently Im using this kind of solutions:
function executeWithHiddenParameters(callback){
const {a,b,c} = allParameters
return callback( {a,b,c} );
}
somehow to me it seems a bit cumbersome to initialize the parameters and then create a new object. I suppose when used in large scale this could also be relevant for performance issues?
So my question actually is about object descructuring: What does the destrucuring operator actually return? What is happening under the hood? How can it be used as simple oneliner? (literature and links also very much appreciated :D )