Reputation: 958
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 flag
to 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?
Upvotes: 11
Views: 755
Reputation: 664920
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:
.…
and […]
operatorsUpvotes: 6