Default values of destructured arguments?

Frankie Bagnardi f.bagnardi at gmail.com
Fri Nov 28 07:57:03 PST 2014


Traceur supports the former (6to5 doesn't).  I think both of those should
be valid, the former just because it makes sense (likely why it accidently
works in traceur), and the latter because it's very useful.

http://jsbin.com/bevijekiki/1/edit

These should be equivalent (minus the o variable)

function({d=1}){}
function(o){ var d = o instanceof Object && o.d !== undefined ? o.d : 1 }



On Fri, Nov 28, 2014 at 8:45 AM, Bradley Meck <bradley.meck at gmail.com>
wrote:

> I might be missing something but it appears in es6 you cannot default a
> destructured argument?
>
> ```
> function foo({d}={d:1}) {
>
> }
> ```
>
> and
>
> ```
> function foo({d=1}) {
>
> }
> ```
>
> don't seem to fall into the syntax, are there plans for this in the future
> or something that prevented this?
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141128/04fe7bd0/attachment.html>


More information about the es-discuss mailing list