Destructuring and default parameters in functions

Erik Arvidsson erik.arvidsson at gmail.com
Thu Jun 27 06:56:37 PDT 2013


That should work and it works both in Traceur and Continuum.

On Thu, Jun 27, 2013 at 6:19 AM, Marius Gundersen <gundersen at gmail.com> wrote:
> I'm testing some code in the latest version of Firefox, and it seems I'm not
> able to define default values to function arguments which are destructured.
> For example:
>
>
> function test([a, b] = [1, 2]){
>
>
>     return a+b;
> }
>
>
> test([3, 4])//expect 7
>
> test([3])//expect NaN
>
> test()//expect 3
>
>
> //Exception: missing ) after formal parameters (line 1)
>
>
> I haven't found this defined in the current grammar, but would be useful for
> something I'm currently working on. Or maybe it just isn't implemented in
> Firefox?
>
> Marius Gundersen
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
erik


More information about the es-discuss mailing list