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

后端 未结 3 1584
广开言路
广开言路 2020-12-23 23:45

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         


        
3条回答
  •  [愿得一人]
    2020-12-24 00:43

    The main way to comment is sh/Perl/Ruby/... style # comments:

    # This comment goes to the end of the line
    # and it won't appear in the "compiled"
    # JavaScript version.
    

    You use the block style ### comments when you want a comment to appear in the JavaScript version:

    Sometimes you'd like to pass a block comment through to the generated JavaScript. For example, when you need to embed a licensing header at the top of a file. Block comments, which mirror the syntax for heredocs, are preserved in the generated code.

    So if you start with

    ###
    PancakeParser is Public Domain
    ###
    

    then you'd get this JavaScript comment in the generated JavaScript:

    /*
    PancakeParser is Public Domain
    */
    

提交回复
热议问题