This question already has answers here:
How can I use backslashes (\) in a string?

(4个答案)


去年关闭。



qAnswersR[90430] = [];
    qAnswersR[90430].push("[math]k: \frac{(x+20)^{2}}{256}+\frac{(y-15)^{2}}{81}=1[/math]");

而且我需要将值放入变量中,但是当我用console.log退出数组时,如下所示:
console.log(qAnswersR[90430]);

我得到: [math]k: rac{(x+20)^{2}}{256}+rac{(y-15)^{2}}{81}=1[/math],[math]k: 81(x+20)^{2}+256(y-15)^{2}=20736[/math]

但是转义标记"\"消失了,但是我在那里需要它,我该怎么办?

最佳答案



您需要转义反斜杠,即,使用\\而不是\:

"[math]k: \\frac{(x+20)^{2}}{256}+\\frac{(y-15)^{2}}{81}=1[/math]"
          ^                       ^

关于javascript - 如何使javascript忽略转义(\)字符?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6184453/

10-12 00:09
查看更多