Search code examples
javascriptblockcomments

commenting out code blocks in javascript


I did a google search for the answer but I've probably overlooked something obvious... I wish to comment out a block of code that has the potential to have nested comments, where they can terminate the parent comment 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?


Solution

  • Seems that I can comment 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 'comment out' that if block.