Timeline for Is there a null-coalescing (Elvis) operator or safe navigation operator in javascript?
Current License: CC BY-SA 3.0
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 7, 2011 at 16:42 | comment | added | Frédéric Hamidi |
@Cameron, indeed, but that's mentioned in the question and seems to be the questioner's intent. "" or 0 might be unexpected, though :)
|
|
Jul 7, 2011 at 16:41 | comment | added | Cameron |
+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.
|
|
Jul 7, 2011 at 16:36 | history | answered | Frédéric Hamidi | CC BY-SA 3.0 |