Reputation: 137
Why the first expression can be executed without error , but the second and the third one can not be executed?
Upvotes: 1
Views: 543
Reputation: 522412
The spec allows it:
Unicode escape sequences are permitted in an IdentifierName, where they contribute a single Unicode code point to the IdentifierName. The code point is expressed by the CodePoint of the UnicodeEscapeSequence (see 11.8.4). The
\
preceding the UnicodeEscapeSequence and theu
and{ }
code units, if they appear, do not contribute code points to the IdentifierName. […]
In other words, you can use \u....
escape sequences as replacement for literal characters for identifiers (such as console
). The same allowance is not made for other kinds of escape sequences like \x..
.
Upvotes: 3