Operators ||= and &&=

David-Sarah Hopwood david-sarah at jacaranda.org
Wed May 6 07:31:48 PDT 2009


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?
> 
> 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. 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?

It's not indistinguishable; exactly the first arguments.length parameters
are present, regardless of whether they are undefined.

-- 
David-Sarah Hopwood ⚥



More information about the es-discuss mailing list