Search code examples
javascriptcommentsslash

Can double slashes on comments produce unexpected errors?


I need to know if double // slashes on the URL comment could produce errors:

function jsFunction(){
    //http://google.com
    var str="...";
}

Other than syntax-highlighting-related errors


Solution

  • // are single line comments, anything after it on the same line will be commented out, even more / characters.

    /* is used to begin a multi-line comment. The next */ will end the multi-line comment. This could be an issue if you try comment out a regular expression:

    /**
    var foo = /.*/g
     */