Reputation: 35
the problem occurs only when the word after the '\' begin with 'x'. I would like to know if \x is reserved word.
Upvotes: 1
Views: 267
Reputation: 2253
Backslash is used to escape characters. If you need a literal backslash, use \\
.
Upvotes: 3
Reputation: 33521
It is not a reserved word, it's a way to print a character by its code:
>>> console.log('\x56');
V
In fact, Firebug tells you what's wrong if you omit the number:
SyntaxError: malformed hexadecimal character escape sequence
Like in many C-style languages, backslashes denote "escape sequences". More can be found here.
Upvotes: 7