ES6 destructuring function parameter - naming root object
Is there a way to retain the name of a destructured function argument? I.e., the name of the root object?
In ES5, I might do this (using inheritance as a metaphor to make the point):
// ES5:
var setupParentClass5 = function(options)
textEditor.setup(options.rows, options.columns);
;
var setupChildClass5 = function(options)
rangeSlider.setup(options.minVal, options.maxVal);
setupParentClass5(options); // <= we pass the options object UP
;
I'm using the same options
object to hold multiple configuration parameters. Some parameters are used by the parent class, and some are used by the subclass.
Is there a way to do this with destructured function arguments in ES6?
// ES6:
var setupParentClass6 = (rows, columns) =>
textEditor.setup(rows, columns);
;
var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6( /* ??? */ ); // how to pass the root options object?
;
Or do I need to extract all of the options in setupChildClass6()
so that they can be individually passed into setupParentClass6()
?
// ugh.
var setupChildClass6b = (minVal, maxVal, rows, columns) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rows, columns);
;
javascript function arguments ecmascript-6 destructuring
add a comment |
Is there a way to retain the name of a destructured function argument? I.e., the name of the root object?
In ES5, I might do this (using inheritance as a metaphor to make the point):
// ES5:
var setupParentClass5 = function(options)
textEditor.setup(options.rows, options.columns);
;
var setupChildClass5 = function(options)
rangeSlider.setup(options.minVal, options.maxVal);
setupParentClass5(options); // <= we pass the options object UP
;
I'm using the same options
object to hold multiple configuration parameters. Some parameters are used by the parent class, and some are used by the subclass.
Is there a way to do this with destructured function arguments in ES6?
// ES6:
var setupParentClass6 = (rows, columns) =>
textEditor.setup(rows, columns);
;
var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6( /* ??? */ ); // how to pass the root options object?
;
Or do I need to extract all of the options in setupChildClass6()
so that they can be individually passed into setupParentClass6()
?
// ugh.
var setupChildClass6b = (minVal, maxVal, rows, columns) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rows, columns);
;
javascript function arguments ecmascript-6 destructuring
arguments[0]
would do, but no, you cannot name them at the same time as destructuring.
– Bergi
Oct 17 '15 at 11:24
add a comment |
Is there a way to retain the name of a destructured function argument? I.e., the name of the root object?
In ES5, I might do this (using inheritance as a metaphor to make the point):
// ES5:
var setupParentClass5 = function(options)
textEditor.setup(options.rows, options.columns);
;
var setupChildClass5 = function(options)
rangeSlider.setup(options.minVal, options.maxVal);
setupParentClass5(options); // <= we pass the options object UP
;
I'm using the same options
object to hold multiple configuration parameters. Some parameters are used by the parent class, and some are used by the subclass.
Is there a way to do this with destructured function arguments in ES6?
// ES6:
var setupParentClass6 = (rows, columns) =>
textEditor.setup(rows, columns);
;
var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6( /* ??? */ ); // how to pass the root options object?
;
Or do I need to extract all of the options in setupChildClass6()
so that they can be individually passed into setupParentClass6()
?
// ugh.
var setupChildClass6b = (minVal, maxVal, rows, columns) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rows, columns);
;
javascript function arguments ecmascript-6 destructuring
Is there a way to retain the name of a destructured function argument? I.e., the name of the root object?
In ES5, I might do this (using inheritance as a metaphor to make the point):
// ES5:
var setupParentClass5 = function(options)
textEditor.setup(options.rows, options.columns);
;
var setupChildClass5 = function(options)
rangeSlider.setup(options.minVal, options.maxVal);
setupParentClass5(options); // <= we pass the options object UP
;
I'm using the same options
object to hold multiple configuration parameters. Some parameters are used by the parent class, and some are used by the subclass.
Is there a way to do this with destructured function arguments in ES6?
// ES6:
var setupParentClass6 = (rows, columns) =>
textEditor.setup(rows, columns);
;
var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6( /* ??? */ ); // how to pass the root options object?
;
Or do I need to extract all of the options in setupChildClass6()
so that they can be individually passed into setupParentClass6()
?
// ugh.
var setupChildClass6b = (minVal, maxVal, rows, columns) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rows, columns);
;
javascript function arguments ecmascript-6 destructuring
javascript function arguments ecmascript-6 destructuring
asked Mar 14 '15 at 16:02
jbxjbx
1387
1387
arguments[0]
would do, but no, you cannot name them at the same time as destructuring.
– Bergi
Oct 17 '15 at 11:24
add a comment |
arguments[0]
would do, but no, you cannot name them at the same time as destructuring.
– Bergi
Oct 17 '15 at 11:24
arguments[0]
would do, but no, you cannot name them at the same time as destructuring.– Bergi
Oct 17 '15 at 11:24
arguments[0]
would do, but no, you cannot name them at the same time as destructuring.– Bergi
Oct 17 '15 at 11:24
add a comment |
3 Answers
3
active
oldest
votes
I have the 'options' arguments on too many places myself. I would opt for 1 extra line of code. Not worthy in this example, but a good solution when having destructuring on more lines.
const setupChildClass6 = options =>
const minVal, maxVal = options;
rangeSlider.setup(minVal, maxVal);
setupParentClass6(options);
;
Agreed -- this is what I've been using as well. We've all learned to use es6 much better in the last few months!
– jbx
Dec 9 '15 at 16:58
add a comment |
You cannot do it directly in the arguments, but you can extract the values afterward:
function myFun(allVals)
const val1, val2, val3 = allVals;
console.log("easy access to individual entries:", val2);
console.log("easy access to all entries:", allVals);
And even better, you can useconst
here :-)
– Bergi
Oct 17 '15 at 11:25
Oh but that may depends on what he wants to do with them, don't you think?
– Quentin Roy
Oct 17 '15 at 11:28
Well there are many people who argue thatconst
should be the default. Of course if you wish to reassign, you'd needlet
.
– Bergi
Oct 17 '15 at 12:28
Oh. Ok it makes sense. I'll do an update.
– Quentin Roy
Oct 17 '15 at 13:46
tl;dr poor intellisense. The problem with this approach is that you won't have any indication of allVals structure when using myFun
– Romain Vincent
9 hours ago
|
show 1 more comment
You cannot use destructuring and simple named positional argument for the same parameter at the same time. What you can do:
Use destructuring for
setupParentClass6
function, but old ES6 approach forsetupChildClass6
(I think this is the best choice, just make name shorter):var setupChildClass6 = (o) =>
rangeSlider.setup(o.minVal, o.maxVal);
setupParentClass6(o);
;Use old
arguments
object. Butarguments
can slow down a function (V8 particular), so I think it's a bad approach:var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(arguments[0]);
;ES7 has proposal for rest/spread properties (if you don't need
minVal
andmaxVal
insetupParentCalss6
function):var setupChildClass6b = (minVal, maxVal, ...rest) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rest);
;Unfortunately it's not ES6.
Thanks, super-helpful. Actually #2 is closest to the intention, and the slowdown will not be relevant given how the function is used. For the moment, I'm using Babel, so perhaps it will get rest properties on objects soon.
– jbx
Mar 16 '15 at 21:27
2
The usage ofarguments
as shown in #2 actually is not slow. But I'd consider it unreadable.
– Bergi
Dec 7 '15 at 21:44
1
Rest properties might not solve your problem, as it does takeminVal
andmaxVal
out of theoptions
objects. Beware.
– Bergi
Dec 7 '15 at 21:45
can you elaborate on why and how much using arguments would slow down the function?
– Romain Vincent
9 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29051011%2fes6-destructuring-function-parameter-naming-root-object%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have the 'options' arguments on too many places myself. I would opt for 1 extra line of code. Not worthy in this example, but a good solution when having destructuring on more lines.
const setupChildClass6 = options =>
const minVal, maxVal = options;
rangeSlider.setup(minVal, maxVal);
setupParentClass6(options);
;
Agreed -- this is what I've been using as well. We've all learned to use es6 much better in the last few months!
– jbx
Dec 9 '15 at 16:58
add a comment |
I have the 'options' arguments on too many places myself. I would opt for 1 extra line of code. Not worthy in this example, but a good solution when having destructuring on more lines.
const setupChildClass6 = options =>
const minVal, maxVal = options;
rangeSlider.setup(minVal, maxVal);
setupParentClass6(options);
;
Agreed -- this is what I've been using as well. We've all learned to use es6 much better in the last few months!
– jbx
Dec 9 '15 at 16:58
add a comment |
I have the 'options' arguments on too many places myself. I would opt for 1 extra line of code. Not worthy in this example, but a good solution when having destructuring on more lines.
const setupChildClass6 = options =>
const minVal, maxVal = options;
rangeSlider.setup(minVal, maxVal);
setupParentClass6(options);
;
I have the 'options' arguments on too many places myself. I would opt for 1 extra line of code. Not worthy in this example, but a good solution when having destructuring on more lines.
const setupChildClass6 = options =>
const minVal, maxVal = options;
rangeSlider.setup(minVal, maxVal);
setupParentClass6(options);
;
edited Jan 17 '18 at 15:25
answered Dec 7 '15 at 21:26
Niels SteenbeekNiels Steenbeek
3,56723041
3,56723041
Agreed -- this is what I've been using as well. We've all learned to use es6 much better in the last few months!
– jbx
Dec 9 '15 at 16:58
add a comment |
Agreed -- this is what I've been using as well. We've all learned to use es6 much better in the last few months!
– jbx
Dec 9 '15 at 16:58
Agreed -- this is what I've been using as well. We've all learned to use es6 much better in the last few months!
– jbx
Dec 9 '15 at 16:58
Agreed -- this is what I've been using as well. We've all learned to use es6 much better in the last few months!
– jbx
Dec 9 '15 at 16:58
add a comment |
You cannot do it directly in the arguments, but you can extract the values afterward:
function myFun(allVals)
const val1, val2, val3 = allVals;
console.log("easy access to individual entries:", val2);
console.log("easy access to all entries:", allVals);
And even better, you can useconst
here :-)
– Bergi
Oct 17 '15 at 11:25
Oh but that may depends on what he wants to do with them, don't you think?
– Quentin Roy
Oct 17 '15 at 11:28
Well there are many people who argue thatconst
should be the default. Of course if you wish to reassign, you'd needlet
.
– Bergi
Oct 17 '15 at 12:28
Oh. Ok it makes sense. I'll do an update.
– Quentin Roy
Oct 17 '15 at 13:46
tl;dr poor intellisense. The problem with this approach is that you won't have any indication of allVals structure when using myFun
– Romain Vincent
9 hours ago
|
show 1 more comment
You cannot do it directly in the arguments, but you can extract the values afterward:
function myFun(allVals)
const val1, val2, val3 = allVals;
console.log("easy access to individual entries:", val2);
console.log("easy access to all entries:", allVals);
And even better, you can useconst
here :-)
– Bergi
Oct 17 '15 at 11:25
Oh but that may depends on what he wants to do with them, don't you think?
– Quentin Roy
Oct 17 '15 at 11:28
Well there are many people who argue thatconst
should be the default. Of course if you wish to reassign, you'd needlet
.
– Bergi
Oct 17 '15 at 12:28
Oh. Ok it makes sense. I'll do an update.
– Quentin Roy
Oct 17 '15 at 13:46
tl;dr poor intellisense. The problem with this approach is that you won't have any indication of allVals structure when using myFun
– Romain Vincent
9 hours ago
|
show 1 more comment
You cannot do it directly in the arguments, but you can extract the values afterward:
function myFun(allVals)
const val1, val2, val3 = allVals;
console.log("easy access to individual entries:", val2);
console.log("easy access to all entries:", allVals);
You cannot do it directly in the arguments, but you can extract the values afterward:
function myFun(allVals)
const val1, val2, val3 = allVals;
console.log("easy access to individual entries:", val2);
console.log("easy access to all entries:", allVals);
edited Jan 30 at 22:07
answered Oct 17 '15 at 10:49
Quentin RoyQuentin Roy
5,08911942
5,08911942
And even better, you can useconst
here :-)
– Bergi
Oct 17 '15 at 11:25
Oh but that may depends on what he wants to do with them, don't you think?
– Quentin Roy
Oct 17 '15 at 11:28
Well there are many people who argue thatconst
should be the default. Of course if you wish to reassign, you'd needlet
.
– Bergi
Oct 17 '15 at 12:28
Oh. Ok it makes sense. I'll do an update.
– Quentin Roy
Oct 17 '15 at 13:46
tl;dr poor intellisense. The problem with this approach is that you won't have any indication of allVals structure when using myFun
– Romain Vincent
9 hours ago
|
show 1 more comment
And even better, you can useconst
here :-)
– Bergi
Oct 17 '15 at 11:25
Oh but that may depends on what he wants to do with them, don't you think?
– Quentin Roy
Oct 17 '15 at 11:28
Well there are many people who argue thatconst
should be the default. Of course if you wish to reassign, you'd needlet
.
– Bergi
Oct 17 '15 at 12:28
Oh. Ok it makes sense. I'll do an update.
– Quentin Roy
Oct 17 '15 at 13:46
tl;dr poor intellisense. The problem with this approach is that you won't have any indication of allVals structure when using myFun
– Romain Vincent
9 hours ago
And even better, you can use
const
here :-)– Bergi
Oct 17 '15 at 11:25
And even better, you can use
const
here :-)– Bergi
Oct 17 '15 at 11:25
Oh but that may depends on what he wants to do with them, don't you think?
– Quentin Roy
Oct 17 '15 at 11:28
Oh but that may depends on what he wants to do with them, don't you think?
– Quentin Roy
Oct 17 '15 at 11:28
Well there are many people who argue that
const
should be the default. Of course if you wish to reassign, you'd need let
.– Bergi
Oct 17 '15 at 12:28
Well there are many people who argue that
const
should be the default. Of course if you wish to reassign, you'd need let
.– Bergi
Oct 17 '15 at 12:28
Oh. Ok it makes sense. I'll do an update.
– Quentin Roy
Oct 17 '15 at 13:46
Oh. Ok it makes sense. I'll do an update.
– Quentin Roy
Oct 17 '15 at 13:46
tl;dr poor intellisense. The problem with this approach is that you won't have any indication of allVals structure when using myFun
– Romain Vincent
9 hours ago
tl;dr poor intellisense. The problem with this approach is that you won't have any indication of allVals structure when using myFun
– Romain Vincent
9 hours ago
|
show 1 more comment
You cannot use destructuring and simple named positional argument for the same parameter at the same time. What you can do:
Use destructuring for
setupParentClass6
function, but old ES6 approach forsetupChildClass6
(I think this is the best choice, just make name shorter):var setupChildClass6 = (o) =>
rangeSlider.setup(o.minVal, o.maxVal);
setupParentClass6(o);
;Use old
arguments
object. Butarguments
can slow down a function (V8 particular), so I think it's a bad approach:var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(arguments[0]);
;ES7 has proposal for rest/spread properties (if you don't need
minVal
andmaxVal
insetupParentCalss6
function):var setupChildClass6b = (minVal, maxVal, ...rest) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rest);
;Unfortunately it's not ES6.
Thanks, super-helpful. Actually #2 is closest to the intention, and the slowdown will not be relevant given how the function is used. For the moment, I'm using Babel, so perhaps it will get rest properties on objects soon.
– jbx
Mar 16 '15 at 21:27
2
The usage ofarguments
as shown in #2 actually is not slow. But I'd consider it unreadable.
– Bergi
Dec 7 '15 at 21:44
1
Rest properties might not solve your problem, as it does takeminVal
andmaxVal
out of theoptions
objects. Beware.
– Bergi
Dec 7 '15 at 21:45
can you elaborate on why and how much using arguments would slow down the function?
– Romain Vincent
9 hours ago
add a comment |
You cannot use destructuring and simple named positional argument for the same parameter at the same time. What you can do:
Use destructuring for
setupParentClass6
function, but old ES6 approach forsetupChildClass6
(I think this is the best choice, just make name shorter):var setupChildClass6 = (o) =>
rangeSlider.setup(o.minVal, o.maxVal);
setupParentClass6(o);
;Use old
arguments
object. Butarguments
can slow down a function (V8 particular), so I think it's a bad approach:var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(arguments[0]);
;ES7 has proposal for rest/spread properties (if you don't need
minVal
andmaxVal
insetupParentCalss6
function):var setupChildClass6b = (minVal, maxVal, ...rest) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rest);
;Unfortunately it's not ES6.
Thanks, super-helpful. Actually #2 is closest to the intention, and the slowdown will not be relevant given how the function is used. For the moment, I'm using Babel, so perhaps it will get rest properties on objects soon.
– jbx
Mar 16 '15 at 21:27
2
The usage ofarguments
as shown in #2 actually is not slow. But I'd consider it unreadable.
– Bergi
Dec 7 '15 at 21:44
1
Rest properties might not solve your problem, as it does takeminVal
andmaxVal
out of theoptions
objects. Beware.
– Bergi
Dec 7 '15 at 21:45
can you elaborate on why and how much using arguments would slow down the function?
– Romain Vincent
9 hours ago
add a comment |
You cannot use destructuring and simple named positional argument for the same parameter at the same time. What you can do:
Use destructuring for
setupParentClass6
function, but old ES6 approach forsetupChildClass6
(I think this is the best choice, just make name shorter):var setupChildClass6 = (o) =>
rangeSlider.setup(o.minVal, o.maxVal);
setupParentClass6(o);
;Use old
arguments
object. Butarguments
can slow down a function (V8 particular), so I think it's a bad approach:var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(arguments[0]);
;ES7 has proposal for rest/spread properties (if you don't need
minVal
andmaxVal
insetupParentCalss6
function):var setupChildClass6b = (minVal, maxVal, ...rest) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rest);
;Unfortunately it's not ES6.
You cannot use destructuring and simple named positional argument for the same parameter at the same time. What you can do:
Use destructuring for
setupParentClass6
function, but old ES6 approach forsetupChildClass6
(I think this is the best choice, just make name shorter):var setupChildClass6 = (o) =>
rangeSlider.setup(o.minVal, o.maxVal);
setupParentClass6(o);
;Use old
arguments
object. Butarguments
can slow down a function (V8 particular), so I think it's a bad approach:var setupChildClass6 = (minVal, maxVal) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(arguments[0]);
;ES7 has proposal for rest/spread properties (if you don't need
minVal
andmaxVal
insetupParentCalss6
function):var setupChildClass6b = (minVal, maxVal, ...rest) =>
rangeSlider.setup(minVal, maxVal);
setupParentClass6(rest);
;Unfortunately it's not ES6.
answered Mar 14 '15 at 16:37
alexpodsalexpods
35.7k78088
35.7k78088
Thanks, super-helpful. Actually #2 is closest to the intention, and the slowdown will not be relevant given how the function is used. For the moment, I'm using Babel, so perhaps it will get rest properties on objects soon.
– jbx
Mar 16 '15 at 21:27
2
The usage ofarguments
as shown in #2 actually is not slow. But I'd consider it unreadable.
– Bergi
Dec 7 '15 at 21:44
1
Rest properties might not solve your problem, as it does takeminVal
andmaxVal
out of theoptions
objects. Beware.
– Bergi
Dec 7 '15 at 21:45
can you elaborate on why and how much using arguments would slow down the function?
– Romain Vincent
9 hours ago
add a comment |
Thanks, super-helpful. Actually #2 is closest to the intention, and the slowdown will not be relevant given how the function is used. For the moment, I'm using Babel, so perhaps it will get rest properties on objects soon.
– jbx
Mar 16 '15 at 21:27
2
The usage ofarguments
as shown in #2 actually is not slow. But I'd consider it unreadable.
– Bergi
Dec 7 '15 at 21:44
1
Rest properties might not solve your problem, as it does takeminVal
andmaxVal
out of theoptions
objects. Beware.
– Bergi
Dec 7 '15 at 21:45
can you elaborate on why and how much using arguments would slow down the function?
– Romain Vincent
9 hours ago
Thanks, super-helpful. Actually #2 is closest to the intention, and the slowdown will not be relevant given how the function is used. For the moment, I'm using Babel, so perhaps it will get rest properties on objects soon.
– jbx
Mar 16 '15 at 21:27
Thanks, super-helpful. Actually #2 is closest to the intention, and the slowdown will not be relevant given how the function is used. For the moment, I'm using Babel, so perhaps it will get rest properties on objects soon.
– jbx
Mar 16 '15 at 21:27
2
2
The usage of
arguments
as shown in #2 actually is not slow. But I'd consider it unreadable.– Bergi
Dec 7 '15 at 21:44
The usage of
arguments
as shown in #2 actually is not slow. But I'd consider it unreadable.– Bergi
Dec 7 '15 at 21:44
1
1
Rest properties might not solve your problem, as it does take
minVal
and maxVal
out of the options
objects. Beware.– Bergi
Dec 7 '15 at 21:45
Rest properties might not solve your problem, as it does take
minVal
and maxVal
out of the options
objects. Beware.– Bergi
Dec 7 '15 at 21:45
can you elaborate on why and how much using arguments would slow down the function?
– Romain Vincent
9 hours ago
can you elaborate on why and how much using arguments would slow down the function?
– Romain Vincent
9 hours ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29051011%2fes6-destructuring-function-parameter-naming-root-object%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
arguments[0]
would do, but no, you cannot name them at the same time as destructuring.– Bergi
Oct 17 '15 at 11:24