admin管理员组文章数量:1394534
I did a google search for the answer but I've probably overlooked something obvious... I wish to ment out a block of code that has the potential to have nested ments, where they can terminate the parent ment early. In c I've seen it done like follows:
#if 0
/* Code */
#endif
but js doesn't seem to have standard preprocessor. Is there a way?
I did a google search for the answer but I've probably overlooked something obvious... I wish to ment out a block of code that has the potential to have nested ments, where they can terminate the parent ment early. In c I've seen it done like follows:
#if 0
/* Code */
#endif
but js doesn't seem to have standard preprocessor. Is there a way?
Share Improve this question asked Aug 4, 2012 at 15:46 Rob FRob F 5396 silver badges17 bronze badges4 Answers
Reset to default 4I'd just do something like:
if ( ! "DEBUG" ) {
...
}
Seems that I can ment out any block by doing:
1|| /* code block */
It even works before statements because js seems to treat them as expressions as well, for instance
1|| if(1) /* code */
will 'ment out' that if block.
javascript don't provide preprocessor but you can use use third-party library
http://code.google./p/jsmake-preprocessor/
ex)
/*@ifdef DEBUG_MODE */
console.log("development server is in debug mode!");
/*@end */
Javascript multiline ments, also known as block ments, start with a forward slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/). They do not require a ment delimiter character on every line and may contain newlines
source
本文标签: commenting out code blocks in javascriptStack Overflow
版权声明:本文标题:commenting out code blocks in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744100742a2590860.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论