In PHP I can disable code lines by using #
or 开发者_运维问答//
or /* disabled codes */
.
How do we do it in JS?
You can use //
or /* lala */
in JS as well.
//
will comment all the code afterwards until the next newline
character, examples:
//this whole line is commented. var x=5 has no effect because it's a comment
var x = 5; //x has been set as 5, comment is not whole line.
/*
and */
is used to comment everything between them even if it span more than one line. For example:
/*
The following code will set x as 5
*/
var x = 5; /* yes it can also span only part of line */
Unlike PHP though, #
is not used to comment code, in this JS is more like C/C++/Java languages.
精彩评论