In my Javascript code, I process many json objects with properties that may be null:
if (store.departments != null) {
for(var i = 0; i < store.departments.length; i++) {
alert(department.name);
}
}
In porting my app to coffeescript, I came up with the following shortcut using the existential operator:
for department in store.departments ? []
alert department.name
Is this acceptable coffeescript? Is there any scenario in which this would not work as intended?