Operators ||= and &&=
brendan at mozilla.com
Tue May 5 14:51:35 PDT 2009
On May 5, 2009, at 12:16 PM, liorean wrote:
>> On Tue, May 5, 2009 at 11:37 AM, Peter Michaux <petermichaux at gmail.com
>> > wrote:
>>> function(a=1, b="defaultVal");
>>> And in this syntax will default values be used if the parameter is
>>> falsey or only if it is undefined?
> 2009/5/5 Mark S. Miller <erights at google.com>:
>> Or only if it is absent?
That's how http://wiki.ecmascript.org/doku.php?id=harmony:default_parameter_values
specifies it. Only if absent is an actual argument count vs. formal
parameter count check.
> I've been out of the ECMAScript world for many months now, but IIRC in
> ES3 all formal parameters that are absent gets initiated to the value
> undefined. Not sure which side of the function call border that
> initiation takes place on, though.
-- callee side.
> Wouldn't special casing absence
> from undefined value effectively introduce another state for a
> variable to be in, though, since the behaviour is indistinguishable in
> user code in ES3?
No, no added state is required beyond the existing actual vs. formal
More information about the es-discuss