[英]escape sequences in strings in javascript
i want to write this sentence in 3 lines but on scrimba this does not work but on Repl.lt ( https://repl.it/repls/WickedBaggyRegression ) it works, why? 我想在3行中写这句话,但是在scrimba上却不起作用,但是在Repl.lt( https://repl.it/repls/WickedBaggyRegression )上却可以,为什么?
var myStr = 'FirstLine\n\\SecondLine\\\rThirdLine';
console.log(myStr);
It is probably due to how scrimba.com site does interpret and displays your log in its own custom console. 这可能是由于scrimba.com网站如何在其自定义控制台中解释和显示您的日志。
(it probably wrap the text console.log
receives in a single line.) (它可能会将console.log
接收的文本包装在一行中。)
Try by replacing console.log
by alert
and you will see escape sequences are "preserved" in the alert popup displayed in the simulated browser, which means, they are correct in a JavaScript way : 尝试用alert
替换console.log
,您将在模拟浏览器中显示的警报弹出窗口中看到转义序列被“保留”,这意味着它们以JavaScript方式是正确的:
I also found a course that explain this: https://scrimba.com/p/p4Mrt9/c4vJdha 我还找到了一门解释这一问题的课程: https : //scrimba.com/p/p4Mrt9/c4vJdha
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.