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.

2
  • 17
    +1, I forgot || could be used that way. Be aware that this will coalesce not only when the expression is null, but also when it's undefined, false, 0, or the empty string.
    – Cameron
    Commented Jul 7, 2011 at 16:41
  • @Cameron, indeed, but that's mentioned in the question and seems to be the questioner's intent. "" or 0 might be unexpected, though :) Commented Jul 7, 2011 at 16:42