If you do not want the function to return something, just say return :
kango.invokeAsync 'kango.storage.getItem', 'item1', (returned1) -> kango.invokeAsync 'kango.storage.getItem', 'item2', (returned2) -> alert returned1 + returned2 return
return behaves the same in CoffeeScript as it does in JavaScript, so you can say return if you do not want any particular return value.
If you do not specify an explicit return value using return , the CoffeeScript function will return the value of the last expression so that your CoffeeScript is equivalent:
kango.invokeAsync 'kango.storage.getItem', 'item1', (returned1) -> kango.invokeAsync 'kango.storage.getItem', 'item2', (returned2) -> return alert returned1 + returned2
The result will be the same, although alert returns nothing:
f = -> alert 'x' return x = f()
will give undefined to x , but it will:
f = -> alert 'x' x = f()
source share