开发者

Disabling lines in JavaScript

开发者 https://www.devze.com 2023-02-09 10:37 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消