Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • 11
    The 'Elvis Operator' exists in C# -- but it's called the null coalescing operator (much less exciting) :-)
    – Cameron
    Commented Jul 7, 2011 at 16:34
  • If you want an alternative syntax you can take a look of cofeescript
    – Lime
    Commented Jul 7, 2011 at 16:40
  • 5
    This question is sort of a mess... it is mixing up 3 different operators ? : (ternery operator, spelled out in the question, possibly a typo), ?? (null coalescing, which does exist in JavaScript) and ?. (Elvis) which does NOT exist in JavaScript. The answers do not clarify this distinction very well.
    – JoelFan
    Commented Mar 10, 2015 at 1:40
  • 3
    @JoelFan can you provide a link to documentation regarding proper null-coalescence (??) in javascript? Everything I'm finding so far suggests that JS only has "falsey" coalescing (using ||). Commented Jun 14, 2016 at 15:49
  • 1
    Well, I didn't mean to say that JS literally had ?? but that it had null-coalesce... but even there I was kind of wrong. That being said, I have seen a LOT of JS code that uses || as a null coalesce, despite the falsey pitfalls
    – JoelFan
    Commented Jun 16, 2016 at 20:50