Default values of destructured arguments?

Kevin Smith zenparsing at gmail.com
Fri Nov 28 08:13:45 PST 2014


>
>
> ```
> function foo({d}={d:1}) {
>
> }
> ```
>
> and
>
> ```
> function foo({d=1}) {
>
> }
> ```
>

Both are allowed in ES6.

The second will throw an error if no actual parameter is provided to the
function, however.  (Because you haven't specified a default for the
parameter.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141128/c7591d07/attachment.html>


More information about the es-discuss mailing list