this vs thi\u0073

Mike Samuel mikesamuel at gmail.com
Tue Jun 21 09:58:23 PDT 2011


2011/6/20 Luke Hoban <lukeh at microsoft.com>:
> My read of the spec is that thi\u0073 is a ReservedWord and should not be allowed as an Identifer.  So the following part of the examples quoted below should be an early error:
>
>  var thi\u0073 = 42;
>
> The text in 7.6 seems to address this with:
>
> "All interpretations of identifiers within this specification are based upon their actual characters regardless of whether or not an escape sequence was used to contribute any particular characters."

I don't think this means what you think it means.

I think this means that the identifier foo is the same identifier as f\u006fo.

But in

if (false)
alert(1)

"if" is not an identifier, whereas in

\u0069f(false)
alert(1)

\u0069f is an identifier which would be the same as the identifier
"if" if "if" could appear as an identifier unescaped.

Since "this" is not an identifier but appears explicitly in the text,
that led me to assume that "thi\u0073" should behave differently from
"this".

Every browser I have tested treats the identifier "i\u0066" distinctly
from the keyword "if".
Every browser I have tested treats the identifier "thi\u0073"
distinctly from the keyword "this" in at least some cases, but only FF
passes all the tests I've come up with.


More information about the es-discuss mailing list