Here is my coffeescript code:
if c.urls.voice then c.urls.voice else ""
Does anyone have any ideas about whether there is a better way to write this code in Coffeescript?
Just use the existential operator to assign to a non-existing variable/property:
c.urls.voice ?= ""
Alternatively, if you don't want to assign it but only access with a default value, use the or (or ||) operator:
… = c.urls.voice or "" // equivalent to your if statement
however I guess you're even here actually looking for the existential operator which specifically checks for null and undefined values, not all falsy ones:
… = c.urls.voice ? ""
0,false,null,NaN, and so on, not just undefined.