Reputation: 20915
I tried to make an alert popup with "A" with:
var a = \u0041;
alert(a);
However, I get an error in Chrome Console: Uncaught ReferenceError: A is not defined.
What does that mean? I don't have a variable called A
anywhere.
Upvotes: 3
Views: 1612
Reputation: 18233
\u0041 is the unicode for capital letter A. The interpreter translates it as is, not assuming that it is a string.
To alert the value rather than looking for a variable with that name, do alert("\u0041")
Following your code style, the modified code would look like this:
var a = "\u0041";
alert(a);
Upvotes: 7