简体   繁体   中英

Escape sequences in javascript

I know that there are escape sequences like \\n \\b etc in javascript as like in other programming languages.

alert(\\j)=>alerts j ...So what is the role of \\ here?.Which character is escaped?Is it null character?

None. \\j isn't a recognized escape, so the escaping is ignored and "j" is used instead.

js> "\j"
"j"

Special characters in JavaScript Strings include ' , " , \\ , n , r , t , b , and f , as per JavaScript Special Characters w3schools . Because j is not a special character and \\ is (must itself be escaped to be displayed), it would make sense that the \\ is simply ignored.

\\ plays no role in "\\j" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM