Full explanation of private attributes of FF JavaScript Engine

Source: Internet
Author: User

FF has a lot of private attributes and methods that are easy to understand. They are not supported by ECMAScript, but they are very easy to use. All these attributes are in the form of _ XXXX _.

All private attributes that can be used in FF2.0 JS engine SpiderMonkey1.7 (this should be comprehensive and I will find from the source code)

Java 1.0
_ Count __
Indicates the number of attributes of an object, that is, the attribute with hasOwnProperty being true.

Var o = {a: 1, B: 2 };
Alert (o. _ count __);

_ Parent __
The scopeChain that represents the object definition is generally useful only for function objects and is unpredictable due to some optimizations.

Var o = {a: 1, B: 2 };
Alert (o. _ parent __);

_ Proto __
Indicates that the prototype of an object is a pointer to the prototype chain.

Var o0 = {c: 3}
Var o = {a: 1, B: 2 };
Alert (o. c );
O. _ proto __= o0;
Alert (o. c );

_ DefineGetter __
The function defines the getter of an object attribute, which is similar to C #

Var o = {};
Var a = "Hello! ";
O. _ defineGetter _ ("a", function () {return ;});
Alert (o. );
A = "Hi ";
Alert (o. );

_ DefineSetter __
The function defines the setter of an object attribute.

Var o = {};
Var;
O. _ defineSetter _ ("a", function (v) {a = v ;});
O. a = "Hello! ";
Alert ();

_ LookupGetter __
Check whether a getter exists.
_ LookupSetter __
Check whether a setter exists.

Var o = {};
O. _ defineSetter _ ("a", function (v) {a = v ;});
Alert (o. _ lookupSetter _ (""));

Java 1.5
_ NoSuchMethod __
Behavior when accessing a non-existent attribute of an object

Var obj = {};
Obj. _ noSuchMethod _ = function _ noSuchMethod _ (id, args ){
Alert (id );
}
Obj. OOXX ();
Obj. XXOO ();

Java 1.7
_ Iterator __
The attributes used by the Iterator object can change default behaviors such as for in.

Var range = {from: 1, to: 10 };
Range. _ iterator __= function (){
Return {
Current: this. from,
To: this.,
Next: function (){
If (this. current> this. to) throw StopIteration;
Return this. current ++;
}
}
}
For (var I in range)
Alert (I );

 

Related Article

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.