在JavaScript中注释多行字符串

时间:2013-01-10 12:22:04

标签: javascript string comments multiline

是否有可能在javascript多行字符串中添加注释?

这样的事情:

var string = 'START - \
This is part of my string\
\\ This should be escaped!\
-END ';

// string = 'START - This is part of my string - END';

由于

3 个答案:

答案 0 :(得分:3)

我找到了一种可能性:

var string ='START - \
This is my string'+
// This should be escaped!
' - END';

// string = 'START - This is my string - END'

但它不太好......

答案 1 :(得分:2)

这种方式不可能。你可以这样做:

var s = "multi line" +
        //" line" +
        " string";

答案 2 :(得分:0)

你试过这样的事吗?

var string = 'This is part of your string';
string += 'This is second part of your string'; //Comment yout want to add
string += 'This is thirdpart of your string';