Arrays
Arrays, at their most simple, look very similar to JavaScript.
languages = [ "english", "spanish", "french" ] console.log languages[1]
You may use a trailing comma and it will be compiled away:
languages = [ "english", "spanish", "french", ]
becomes:
var languages; languages = ["english", "spanish", "french"];
Many people prefer this style, as it makes it easier to change the contents of an array or object. And you'll be thankful for this safeguard if you've ever left a trailing comma in a JavaScript array, only to discover (always at a very inconvenient time) that it causes an execution-halting error in one particular browser. The browser in question will remain unnamed for the sake of our collective blood pressure. I want this book to be a book about nice things. Happy things.
If you're feeling daring, you can eschew commas altogether. That's right! When the members of your array are declared on separate lines, you may omit the commas and CoffeeScript will still know what to do.
languages...