是否有可能在JavaScript多行字符串中添加註釋?JavaScript中多行字符串的註釋
事情是這樣的:
var string = 'START - \
This is part of my string\
\\ This should be escaped!\
-END ';
// string = 'START - This is part of my string - END';
感謝
是否有可能在JavaScript多行字符串中添加註釋?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 s = "multi line" +
//" line" +
" string";
我發現了一種可能性:
var string ='START - \
This is my string'+
// This should be escaped!
' - END';
// string = 'START - This is my string - END'
但它不是那麼好看...
總比沒有好。有時候我真的想用多行字符串來評論一些東西來進行實驗。 –
你有沒有嘗試這樣的事情?
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';
你爲什麼要那樣做? –
添加對長字符串的評論 – Charles
我不認爲除了你自己的答案之外還有其他選擇。 –