this vs thi\u0073

Luke Hoban lukeh at
Mon Jun 20 16:50:41 PDT 2011

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."


-----Original Message-----
From: es-discuss-bounces at [mailto:es-discuss-bounces at] On Behalf Of Mike Samuel
Sent: Monday, June 20, 2011 2:18 PM
To: Oliver Hunt
Cc: es-discuss
Subject: Re: this vs thi\u0073

2011/6/20 Oliver Hunt <oliver at>:
> Without looking at the spec but just based on what I know our lexer (JSC) does, we won't consider any identifier with escaped characters to be a keyword, so yes you could make identifiers that technically match language keywords, but you'd never be able to use them directly (without escaping).

You can due to global object aliasing.

  var thi\u0073 = 42;
  alert([this.this === 42,  // Look ma, no escaping!
          this["this"] === 42]);  // Look ma, still no escaping!

works in Firefox.

The first is legal because MemberExpression is defined as
     MemberExpression . IdentifierName
     MemberExpression . Identifier
and it is only Identifier that is not allowed to be a reserved word
     Identifier :: IdentifierName but not ReservedWord
     IdentifierName :: IdentifierStart
          | IdentifierName IdentifierPart _______________________________________________
es-discuss mailing list
es-discuss at

More information about the es-discuss mailing list