Can you create a JavaScript string without using ' or " quotes?

前端 未结 5 1632
生来不讨喜
生来不讨喜 2020-12-15 12:51

I have a JS file with some XML in it, where the XML is supposed to get converted to a word by the server.

E.g.

var ip = \"

        
5条回答
  •  生来不讨喜
    2020-12-15 13:06

    You can't create a string without using a single or double quote, as even calling the String() prototype object directly still requires you to pass it the string.

    Inside XML you would use CDATA, but inside JS you'll have to just escape the '\"strings\"' "\'appropriately\'"

提交回复
热议问题