3

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

像这样的东西:

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

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

谢谢

4

3 回答 3

4

我发现了一种可能性:

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

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

但这不是很好...

于 2013-01-10T12:25:05.633 回答
3

这是不可能的。你可以做:

var s = "multi line" +
        //" line" +
        " string";
于 2013-01-10T12:27:44.337 回答
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';
于 2013-01-10T12:27:40.753 回答