What is `base value` of `reference` in ECMAScript(ECMA-262 5.1)?

后端 未结 1 1695
清酒与你
清酒与你 2021-02-05 23:56

I\'ve been trying to understand how this value is set in javascript, and found ECMAScript Language Specification pretty much helpful. I was reading section 8.7

1条回答
  •  梦毁少年i
    2021-02-06 00:08

    Yes, the base value is the context in which the referenced name lives.

    For an object property, this would be the object (see §8.12 Object internal methods for setter/getter operations). For a variable, this would be the variable environment (§10.2.1 Environment records). For an unresolvable reference (the things that throw reference errors except when supplied to typeof), this would be undefined.

    it does not say how it is set

    Reference values are only constructed by very few operations:

    • identifier reference expressions, that resolve the identifier in the current lexical environment (or one of its parents)
    • property accessor expressions, i.e. the .… and […] operators
    • function calls to host functions are permitted to return them, but such don't exist.

    0 讨论(0)
提交回复
热议问题