JavaScript comment starting with /*!

前端 未结 3 1738
孤街浪徒
孤街浪徒 2020-12-16 22:55

My editor (Geany) changes the colour of a comment when a comment starts with /*!. What\'s the difference between /* ... */ and /*! ... */

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 23:30

    They are both treated as comments in JavaScript. For the second one, since the exclamation is inside, JavaScript doesn't care what's inside the comment anyway.

    Tools that minimizes or compresses JavaScript files would get rid of anything inside /* ... */, but would leave the second style of comment intact. The reason is so that there's a way to keep the copyright information in the minified or compressed version of JavaScript files.

提交回复
热议问题