Can we restructure destructured parameters in javascript [duplicate]
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)
javascript ecmascript-6
marked as duplicate by Bergi
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.
add a comment |
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)
javascript ecmascript-6
marked as duplicate by Bergi
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 andfunction1
. it is quite unclear if you hand over an array or a single object and what signature do you have forfunction1
.
– Nina Scholz
Nov 12 at 10:25
add a comment |
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)
javascript ecmascript-6
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
javascript ecmascript-6
edited Nov 12 at 10:52
asked Nov 12 at 10:17
Hassan Naqvi
345
345
marked as duplicate by Bergi
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
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 andfunction1
. it is quite unclear if you hand over an array or a single object and what signature do you have forfunction1
.
– Nina Scholz
Nov 12 at 10:25
add a comment |
2
Consider destructuring in the function body?
– evolutionxbox
Nov 12 at 10:23
please add an example of the call of function without name andfunction1
. it is quite unclear if you hand over an array or a single object and what signature do you have forfunction1
.
– 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
add a comment |
1 Answer
1
active
oldest
votes
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);
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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);
add a comment |
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);
add a comment |
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);
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);
answered Nov 12 at 10:27
Artyom Amiryan
1,770113
1,770113
add a comment |
add a comment |
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 forfunction1
.– Nina Scholz
Nov 12 at 10:25