How do I comment in CoffeeScript? "/* this */" doesn't work

Eric Hu picture Eric Hu · Oct 16, 2011 · Viewed 73.6k times · Source

In what ways can you comment in CoffeeScript?

The documentation say you can use three hash symbols to start and close a comment block:

###
  Comments
  go
  here
###

I've found that I can sometimes use the following two formats

`// backticks allow for straight-JavaScript,
 // but the closing backtick can't be on a comment line (I think?)
`

Are there a simpler way to insert short comments in CoffeeScript?

Do NOT use this style**

Since this is getting a lot of views, I want to emphasize that

/* Comment goes here */

produces a MATH error when the /* is on its own line.

As Trevor pointed out in a comment on the question, this is a regular expression, NOT a comment!

Answer

Michael Durrant picture Michael Durrant · Oct 16, 2011

Use a single # sign

# like this

One character seems pretty minimal ;)

Also:

###
This block comment (useful for ©-Copyright info) also gets 
passed on to the browsers HTML /* like this! */
###