Original author: fictiony
From: Blue Ideal
I compiled it when I wrote a set of models myself and posted it for everyone to see. I hope it will be helpful to everyone.
property:
This property is defined in the class's prototype. After the object instance is created, it can be called by the object instance through the __proto__ chain and points to the constructor of the current class. This can determine which class an object directly belongs to (unlike instanceof, instanceof is not limited to the class that the object directly belongs to, even the parent class returns true).
[Example]
trace( == Object); //Output true
var a = new Object();
trace( == Object); //Output true
var b = new Array();
trace( == Array); //Output true
trace( == Object); //Output false
trace(b instanceof Object); //Output true
Property: Object.__constructor__
This property is similar to the function, the difference is that it is not defined in the prototype of the class, but is attached to the object instance when the object instance is created. At the same time, this property is also called implicitly when used by the super keyword as the parent class constructor, and is used to point to the parent class constructor, that is, super(...) is equivalent to this.__constructor__.call(this,...).
[Example]
trace(.__constructor__== Object); //Output false
var a = new Object();
trace(a.__constructor__== Object); //Output true
var b = new Array();
trace(b.__constructor__== Array); //Output true
trace(b.__constructor__== Object); //Output false
Method: (classFunc)
This method is used to determine whether the current object is in the __proto__ chain of object obj. This method can be used to determine whether a class is a parent or child of another class.
[Example]
trace((new Object())); //Output true
trace((new Array())); //Output true
trace((new Object())); //Output false
trace(()); //Judge whether the Object is Array's parent class, output true
Method: (propName)
This method is used to determine whether a member named propName exists in the current object and can be enumerated (using for..in), in other words, whether it is visible (using the ASSetPropFlags global function to set whether the object properties are visible).
[Example]
var a = {x:1, y:2};
ASSetPropFlags(a, ["y"], 1); //Set y is invisible
trace(); //Only output 2
for (var i in a) trace(i); //Only output x
trace(("x")); //Output true
trace(("y")); //Output false
Method: (propName)
This method is used to determine whether a member named propName is a member of the current object itself, rather than referenced from the class's prototype through the __proto__ chain.
[Example]
function test () {}
= 1;
var a = new test();
= 2;
trace(); //Output 1
trace(("x")); //Output false
trace(); //Output 2
trace(("y")); //Output true
method:()
This method can define the string result generated by an object when converted to a string type, which is generally defined in the class prototype.
[Example]
function point (x, y) {
= x;
= y;
}
= function () {
return "[x:" + + ", y:" + + "]";
};
var pos = new point(10, 20);
trace("position is " + pos); //Output position is [x:10, y:20]
From: Blue Ideal
I compiled it when I wrote a set of models myself and posted it for everyone to see. I hope it will be helpful to everyone.
property:
This property is defined in the class's prototype. After the object instance is created, it can be called by the object instance through the __proto__ chain and points to the constructor of the current class. This can determine which class an object directly belongs to (unlike instanceof, instanceof is not limited to the class that the object directly belongs to, even the parent class returns true).
[Example]
trace( == Object); //Output true
var a = new Object();
trace( == Object); //Output true
var b = new Array();
trace( == Array); //Output true
trace( == Object); //Output false
trace(b instanceof Object); //Output true
Property: Object.__constructor__
This property is similar to the function, the difference is that it is not defined in the prototype of the class, but is attached to the object instance when the object instance is created. At the same time, this property is also called implicitly when used by the super keyword as the parent class constructor, and is used to point to the parent class constructor, that is, super(...) is equivalent to this.__constructor__.call(this,...).
[Example]
trace(.__constructor__== Object); //Output false
var a = new Object();
trace(a.__constructor__== Object); //Output true
var b = new Array();
trace(b.__constructor__== Array); //Output true
trace(b.__constructor__== Object); //Output false
Method: (classFunc)
This method is used to determine whether the current object is in the __proto__ chain of object obj. This method can be used to determine whether a class is a parent or child of another class.
[Example]
trace((new Object())); //Output true
trace((new Array())); //Output true
trace((new Object())); //Output false
trace(()); //Judge whether the Object is Array's parent class, output true
Method: (propName)
This method is used to determine whether a member named propName exists in the current object and can be enumerated (using for..in), in other words, whether it is visible (using the ASSetPropFlags global function to set whether the object properties are visible).
[Example]
var a = {x:1, y:2};
ASSetPropFlags(a, ["y"], 1); //Set y is invisible
trace(); //Only output 2
for (var i in a) trace(i); //Only output x
trace(("x")); //Output true
trace(("y")); //Output false
Method: (propName)
This method is used to determine whether a member named propName is a member of the current object itself, rather than referenced from the class's prototype through the __proto__ chain.
[Example]
function test () {}
= 1;
var a = new test();
= 2;
trace(); //Output 1
trace(("x")); //Output false
trace(); //Output 2
trace(("y")); //Output true
method:()
This method can define the string result generated by an object when converted to a string type, which is generally defined in the class prototype.
[Example]
function point (x, y) {
= x;
= y;
}
= function () {
return "[x:" + + ", y:" + + "]";
};
var pos = new point(10, 20);
trace("position is " + pos); //Output position is [x:10, y:20]