0

I just went through the documentation of ECMAScript 2018 [https://www.ecma-international.org/ecma-262/9.0/index.html#sec-lexical-environments] and ECMAScript 2015 [http://www.ecma-international.org/ecma-262/6.0/#sec-lexical-environments] to understand the difference between the Lexical Environment and Environment Records. But now I'm bit confused about how the Lexical Environment and Environment Records and defined in these specifications. Each of these documents does not specifically state that where this bindings need to reside. Please tell me which definition is correct with respect to the ExecutionContexts, and does it has some changes when it comes to those two specifications?

ExecutionContext {
  LexicalEnvironment : {
    EnvironementReocrd : {
      - type
      - attributes,
      - this binding // Binding to this
    },
    outter, // Reference to the outer Lexical Environment.
  },
  VariableEnvironment : {
    .....
  }
}

or this ??

ExecutionContext {
  LexicalEnvironment: {
    EnvironementReocrd : {
      - type
      - attributes,
    },
    outter, // Reference to the outer Lexical Environment.
    - this binding // Binding to this
  },
  VariableEnvironment : {
    .....
  },
}
Chamika
  • 51
  • 1
  • 1
  • 1
    The `this` binding is part of the environment record. As the spec says: *" A Lexical Environment consists of an Environment Record and a possibly null reference to an outer Lexical Environment."* There isn't more to it. https://www.ecma-international.org/ecma-262/9.0/index.html#table-15 lists the "actions" that can be performed on environment records, one of them being "HasThisBinding" which is defined as: *"Determine if an Environment Record establishes a this binding. Return true if it does and false if it does not."* – Felix Kling Jan 23 '19 at 00:28
  • @FelixKling, That what I also thought. But on the internet, so many articles point out that in the other way around, Thanks for the reply. I wanted some expert advice to get confirmed it. :) Thanks again. – Chamika Jan 24 '19 at 17:45

0 Answers0