For an example of this: reference to the code in the third edition of the Advanced Program This is more complex than what is described in the ECMA. A lot of me didn't read it.

Source: Internet
Author: User
Tags getbase

To understand how this value changes, learn a lot about the knowledge points. Here I'll simply describe how the value of this change.10.1.6active object When you control the execution context into the function code, create an active object and associate it with the execution context, and initialize the object with a property named arguments with the feature {Dontdelete}. The initial value of this property is a parameter object that will be described later. Next, the active object will be used as a mutable object for variable initialization. The active object is purely a normative mechanism, and it is impossible to access it in ECMAScript. Only its members, not the active object itself, can be accessed. When the call operator is applied to a base object's reference value for the active object, the Thisvalue isNULL. 10.1.7This for each execution context, there is a Thisvalues are associated with them. This value is determined by the type of caller and the code being executed when the control enters the execution context. Associated with the execution context. ThisThe value is non-volatile.

8.7Reference type
The internal reference type is not the data type of the language. It is defined in this specification for the purpose of explaining the gist.ECMAScriptReal
The behavior of the current generation and manipulation of intrinsic properties must be the method described here. Moreover, the typeReferenceValue is only used
The middle value of the expression evaluation and cannot be stored by the object's properties.
Reference types are used to interpret suchDelete、typeofand assignment operators. For example, the left side of the assignment
Count is expected to produce a reference. As an alternative, for the left operand of the assignment operator, the assignment behavior is used to interpretIts entire syntactic form is parsed, but it is somewhat difficult to explain the problem of allowing a function call to return a reference. We are pure
The level allows this possibility for the host object. Non-built-in, as defined in this specificationECMAScriptfunction returns an argument
, but there is no preparation for a user-defined function return reference. (another reason is that not using syntactic analysis will
Become lengthy and awkward, affecting many parts of this specification. )
Referenceis a reference to the property of the object. A reference consists of a two-part component,Base Object(Base Object)AndIs
Sex name(property name)
This specification uses the following abstract operation to access the referenced component.
•GetBase (V)。 Returns A Base Object component that references V.
• getpropertyname (V)
**
Algorithmic steps for reference types
GetValue (V)
1. If Type (V) is not Reference, returnV.
2. Call GetBase (V).
3. If Result (2) isNULL, throw aReferenceerrorexception.
4. Call the [[Get]] method of Result (2), passing Getpropertyname (V) for the property name.
5. Return Result (4).
**
I will not translate these English.//This is the third edition of the ECMA knowledge. The following example shows a shorthandvarName = "the window";varObject ={name:"My Object", Getnamefunc:function(){return function(){return This. Name;//The reason this is a global object is because the calling function Getnamefunc () return is a function object, and in the second call to return this function, the ECMA said that this function object is not a value like a reference type, so its base object is null, Its value is implicitly converted to a global object, and then the value of this is determined with this base object. However, this value is undefined in ESC5 and is not converted. };}}; Alert (Object.getnamefunc () ()); //"The Window" (in non-strict mode)

An example of a senior
var name = "the window";
var object = {
Name: "My Object",
Getname:function () {
return this.name;
}
};
The GetName () method here simply returns the value of THIS.name. The following are several calls to Object.getname ()
Methods and their respective results.
Object.getname (); "My Object"
(Object.getname) (); The "My Object"///Group expression returns a value, but this value is not used for GetValue, so when the function call () interpreter uses some of the algorithm steps in the ECMA to determine the value of this, the value of the base object, object, is this value, is because of the algorithm process: if he is an internal reference type, then GetBase (Reference) to it, get the base object to use it to determine the value of this.
(Object.getname = object.getname) (); "The Window", in non-strict mode//= expression returns a function object This object is not a reference type. So the call was based on the example I explained above. The base object is empty. is transferred to the global, determining the value of this.

For an example of this: reference to the code in the third edition of the Advanced Program This is more complex than what is described in the ECMA. A lot of me didn't read it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.