this vs thi\u0073

Mike Samuel mikesamuel at
Mon Jun 20 14:17:37 PDT 2011

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

More information about the es-discuss mailing list