More fun with undefined
Herby Vojčík
herby at mailbox.sk
Fri Jun 15 00:21:13 PDT 2012
T.J. Crowder wrote:
> On 15 June 2012 07:42, Herby Vojčík <herby at mailbox.sk
> <mailto:herby at mailbox.sk>> wrote:
>
>
>
> T.J. Crowder wrote:
>
> Making a point of making this a separate thread from the current
> ?? and
> ??= thread(s), which are thankfully looking close to consensus. So
> that's infix and assignment.
>
> Question: Should we consider unary as well?
>
>
> I also thought in these lines. What I came up is this:
>
> (foo??) // (foo !== undefined)
> foo??bar // (foo !== undefined) ? foo : bar aka foo ?? foo : bar
>
> that is, allow ?? also without the operand, but then only at the end
> of (sub)expression
>
>
> Again, let's consider whether the semantics are worth it before we get
> into synxtax. I take it you're in favor of something?
Well, now that I think about it... whatever. I can live with both.
Though "trueish" !== undefined seems more natural to me (especially
inside if).
If the new syntax is clear that it's otherwise, it can be === undefined,
as well.
For example if (isnt foo) {...} (but this immediately suggest there can
be unary is as well... which is nice, there could be both).
> P.S.: foo??bar:baz wouldn't hurt either, to complete the triad.
>
>
> I've suggested that a couple of times.[1][2] Brendan said he thought it
> was "too thin."[3] AFAIK no one else has weighed in on the subject.
I know, I just sort-of included it to show I like it.
> [1] https://mail.mozilla.org/pipermail/es-discuss/2012-June/023356.html
> [2] https://mail.mozilla.org/pipermail/es-discuss/2012-June/023465.html
> [3] https://mail.mozilla.org/pipermail/es-discuss/2012-June/023468.html
>
> -- T.J.
Herby
More information about the es-discuss
mailing list