Operators ||= and &&=

Brendan Eich brendan at mozilla.com
Wed May 6 16:33:44 PDT 2009

On May 6, 2009, at 3:13 PM, Neil Mix wrote:

> On May 6, 2009, at 4:53 PM, Ash Berlin wrote:
>>>> You could make a case for adding a ?? operator for symmetry.  
>>>> Example of usage:
>>>> some_func(a, b ?? "c" );
>>> Roger that, given ??= it would be strange to leave out ??.
>>> I'm still trying to leave out both ;-).
>>> /be
>> I'm quite partial to an undefined-or operator :)
> Wouldn't it make more sense to have ||| and &&& operators?  We're  
> really just discussing a different form of boolean logic here, why  
> not go-the-distance and draw parallels to ===.  (I think I'm proving  
> Brendan's point :P)

Which point? ;-)

I tried like hell in 1996-7 to get == and != to be what became ===  
and !==, in JS1.2, at the same time ES1 was being standardized. At  
that point Microsoft had less market share than Netscape and therefore  
did not want to risk "breaking the web", so we standardized == and !=  
as the crap-tastic non-equivalence relations they are, and added ===  
and !==.

(Adding better forms and hoping to deprecate their precursors is a  
constant theme on the Web; nothing against Microsoft's position here,  
from this remove in time.)

With the current topic, IMHO there's nothing wrong with || to "fix".  
The boolish (truthy/falsy) tolerance and value-preserving, short- 
circuiting evaluation model are good things in general. So a different  
form for a different operator should be used. And C# is our cousin in  
Ecma, ECMA-334, which if it has been maintained, has ?? (if not ??=)  
in it by now.


More information about the es-discuss mailing list