On Tue, Jun 12, 2012 at 1:37 PM, Peter van der Zee <[email protected]> wrote: > On Tue, Jun 12, 2012 at 5:29 PM, T.J. Crowder <[email protected]> > wrote: >> In the current default operator strawman[1], the operator is ??, e.g.: >> >> a = b ?? 5; >> >> is shorthand for >> >> a = b !== undefined ? b : 5; > > I missed this discussion. What validates the introduction of this > syntax over the equally simple and already possible `a = b || 5`? Is > the comparison to `undefined` (and why not `==null` as well??) really > worth the introduction (and subsequent loss of future usage) of the > double question mark? Whatever it's usual name is (double wat?).
If b is falsey (0, false, null), it'll use the 5, even though you only intended it to be used when b is undefined. "undefined" is special-cased here because it's an extremely common value to check against. It's used when an argument isn't supplied, or when you try to pull a non-existent property off of an object. ~TJ _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

