JavaScript中的多行字符串注释

Comment in multiline string in JavaScript

本文关键字:字符串 注释 JavaScript      更新时间:2023-09-26

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

像这样:

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

谢谢

我发现了一种可能性:

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

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

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

你试过这样做吗?

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';