Default argument values

Steven Mascaro subs at voracity.org
Wed Feb 27 18:35:42 PST 2008


2008/2/28 Brendan Eich <brendan at mozilla.org>:
>  I search like so:
>
>  http://www.google.com/search?hl=en&q=site%3Amail.mozilla.org+es4-
>  discuss+%22named+parameters%22+brendan

Ah. I kept searching for variants of 'default parameters'.

>  This is not to knock named parameters, just to explain why they never
>  made it into a serious proposal in the modern ES4 era.

That sounds fine. The only thing it misses is interchanging positional
and named parameters, but that's no big deal. Will default values work
by doing the following?

function foo({option1, crud2, frob} = {option1: 1, crud2: "dirty",
frob: "enius"}) { ... }

A bit cumbersome, but otherwise OK. I tried in the RI, but it throws a
ParseError. Though both the following give the same error as well:

function foo({option1, curd2, frob}) {}
({x, y} = {x: 42, y: 37})



More information about the Es4-discuss mailing list