Can we restructure destructured parameters in javascript [duplicate]










0















This question already has an answer here:



  • Naming destructured argument objects [duplicate]

    1 answer



I have destructured my parameters in a function like so:



const obj = a:1 , b:2, c:3, d:4
function1(obj);

function1 (a , b, c ,d)
console.log(a);
console.log(b);



now i need to pass all my params into another function. Is there a way I can acheive something like this?



const obj = a:1 , b:2, c:3, d:4
function1(obj);

function1 (a , b, c ,d)
console.log(a);
console.log(b);
func2(allMyParams) //instead of func2(a,b,c,d)










share|improve this question















marked as duplicate by Bergi ecmascript-6
Users with the  ecmascript-6 badge can single-handedly close ecmascript-6 questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 at 11:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    Consider destructuring in the function body?
    – evolutionxbox
    Nov 12 at 10:23










  • please add an example of the call of function without name and function1. it is quite unclear if you hand over an array or a single object and what signature do you have for function1.
    – Nina Scholz
    Nov 12 at 10:25















0















This question already has an answer here:



  • Naming destructured argument objects [duplicate]

    1 answer



I have destructured my parameters in a function like so:



const obj = a:1 , b:2, c:3, d:4
function1(obj);

function1 (a , b, c ,d)
console.log(a);
console.log(b);



now i need to pass all my params into another function. Is there a way I can acheive something like this?



const obj = a:1 , b:2, c:3, d:4
function1(obj);

function1 (a , b, c ,d)
console.log(a);
console.log(b);
func2(allMyParams) //instead of func2(a,b,c,d)










share|improve this question















marked as duplicate by Bergi ecmascript-6
Users with the  ecmascript-6 badge can single-handedly close ecmascript-6 questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 at 11:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    Consider destructuring in the function body?
    – evolutionxbox
    Nov 12 at 10:23










  • please add an example of the call of function without name and function1. it is quite unclear if you hand over an array or a single object and what signature do you have for function1.
    – Nina Scholz
    Nov 12 at 10:25













0












0








0








This question already has an answer here:



  • Naming destructured argument objects [duplicate]

    1 answer



I have destructured my parameters in a function like so:



const obj = a:1 , b:2, c:3, d:4
function1(obj);

function1 (a , b, c ,d)
console.log(a);
console.log(b);



now i need to pass all my params into another function. Is there a way I can acheive something like this?



const obj = a:1 , b:2, c:3, d:4
function1(obj);

function1 (a , b, c ,d)
console.log(a);
console.log(b);
func2(allMyParams) //instead of func2(a,b,c,d)










share|improve this question
















This question already has an answer here:



  • Naming destructured argument objects [duplicate]

    1 answer



I have destructured my parameters in a function like so:



const obj = a:1 , b:2, c:3, d:4
function1(obj);

function1 (a , b, c ,d)
console.log(a);
console.log(b);



now i need to pass all my params into another function. Is there a way I can acheive something like this?



const obj = a:1 , b:2, c:3, d:4
function1(obj);

function1 (a , b, c ,d)
console.log(a);
console.log(b);
func2(allMyParams) //instead of func2(a,b,c,d)





This question already has an answer here:



  • Naming destructured argument objects [duplicate]

    1 answer







javascript ecmascript-6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 10:52

























asked Nov 12 at 10:17









Hassan Naqvi

345




345




marked as duplicate by Bergi ecmascript-6
Users with the  ecmascript-6 badge can single-handedly close ecmascript-6 questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 at 11:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Bergi ecmascript-6
Users with the  ecmascript-6 badge can single-handedly close ecmascript-6 questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 at 11:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 2




    Consider destructuring in the function body?
    – evolutionxbox
    Nov 12 at 10:23










  • please add an example of the call of function without name and function1. it is quite unclear if you hand over an array or a single object and what signature do you have for function1.
    – Nina Scholz
    Nov 12 at 10:25












  • 2




    Consider destructuring in the function body?
    – evolutionxbox
    Nov 12 at 10:23










  • please add an example of the call of function without name and function1. it is quite unclear if you hand over an array or a single object and what signature do you have for function1.
    – Nina Scholz
    Nov 12 at 10:25







2




2




Consider destructuring in the function body?
– evolutionxbox
Nov 12 at 10:23




Consider destructuring in the function body?
– evolutionxbox
Nov 12 at 10:23












please add an example of the call of function without name and function1. it is quite unclear if you hand over an array or a single object and what signature do you have for function1.
– Nina Scholz
Nov 12 at 10:25




please add an example of the call of function without name and function1. it is quite unclear if you hand over an array or a single object and what signature do you have for function1.
– Nina Scholz
Nov 12 at 10:25












1 Answer
1






active

oldest

votes


















0














you can use arguments array like object, which contains all passed parameters, since you passed 1 parameter, you can pass it to another function via arguments[0]






function asd (a , b, c ,d) 
console.log(a);
console.log(b);
aa(arguments[0])


function aa(a)
console.log(a);


asd(a:1,b:2, c:3, d:4);








share|improve this answer



























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    you can use arguments array like object, which contains all passed parameters, since you passed 1 parameter, you can pass it to another function via arguments[0]






    function asd (a , b, c ,d) 
    console.log(a);
    console.log(b);
    aa(arguments[0])


    function aa(a)
    console.log(a);


    asd(a:1,b:2, c:3, d:4);








    share|improve this answer

























      0














      you can use arguments array like object, which contains all passed parameters, since you passed 1 parameter, you can pass it to another function via arguments[0]






      function asd (a , b, c ,d) 
      console.log(a);
      console.log(b);
      aa(arguments[0])


      function aa(a)
      console.log(a);


      asd(a:1,b:2, c:3, d:4);








      share|improve this answer























        0












        0








        0






        you can use arguments array like object, which contains all passed parameters, since you passed 1 parameter, you can pass it to another function via arguments[0]






        function asd (a , b, c ,d) 
        console.log(a);
        console.log(b);
        aa(arguments[0])


        function aa(a)
        console.log(a);


        asd(a:1,b:2, c:3, d:4);








        share|improve this answer












        you can use arguments array like object, which contains all passed parameters, since you passed 1 parameter, you can pass it to another function via arguments[0]






        function asd (a , b, c ,d) 
        console.log(a);
        console.log(b);
        aa(arguments[0])


        function aa(a)
        console.log(a);


        asd(a:1,b:2, c:3, d:4);








        function asd (a , b, c ,d) 
        console.log(a);
        console.log(b);
        aa(arguments[0])


        function aa(a)
        console.log(a);


        asd(a:1,b:2, c:3, d:4);





        function asd (a , b, c ,d) 
        console.log(a);
        console.log(b);
        aa(arguments[0])


        function aa(a)
        console.log(a);


        asd(a:1,b:2, c:3, d:4);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 10:27









        Artyom Amiryan

        1,770113




        1,770113













            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            政党