Default argument values

Steven Mascaro subs at
Fri Feb 29 18:37:38 PST 2008

On 29/02/2008, Lars Hansen <lhansen at> wrote:
> What I meant was an assignment operator so that I could write:
>   { xProp: x, yProp: y } ?= { xProp: 10, yProp: 20 };
>  and x and y would be overwritten only if their values were undefined.
>  C# has a similar operator for conditional assignment which assigns if
>  the lhs value is null (??= or something like that, I'm offline and
>  away from my bookshelf right now).
>  How this fits into default arguments I don't know for sure.  I
>  superficially imagined that ?= would replace = in the parameter list:
>   function f({ xProp: x, yProp:y } ?= { xProp: 10, yProp: 20 }) ...
>  The meaning of that should be intuitive and requires fairly lightweight
>  changes only.
>  Lest I get myself into another "goto" problem, I'll make it clear that
>  I'm not advocating this for ES4.  We're IMO past all deadlines for
>  new design.  I'm just thinking out loud, for the benefit of ES5 :-)

Fair enough. Although I also hope optional named arguments will make
an appearance in ES5. (They're quite a priority for me personally.)

More information about the Es4-discuss mailing list