Space in javascript
When a string constant "\t \n \s"
is created to a JavaScript string, it converts \t
to a tab character, \n
to a newline, and \s
to s
.
This is why you cannot replace \
with \\
, as there is no symbol in relation to JavaScript \
. There is only tab, newline, and s
.
By the way, the result is slashEscape("\t \n \s");
not "s"
. This is actually:
"
s"
It's a tab on the first line, newline, then s.
source to share