Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 reference specification type and found that reference in ECMAScript is made of 3 component, base value, referenced name, strict reference flagto understand section 11.2.3.

I can assume what are referenced name and strict reference flag from their name, but i don't understand what is the base value. The document says that base value is either undefined, String, Boolean, Number and Object, but it does not say how it is set and what it is. I am guessing it is something similar to context object. Could anyone explain?

like image 297
ringord Avatar asked Mar 30 '15 18:03

ringord


1 Answers

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.
like image 123
Bergi Avatar answered Oct 20 '22 04:10

Bergi