User Guide
Object.constructor 665
Object.constructor
Availability
Flash Player 5
Usage
myObject.constructor
Description
Property; reference to the constructor function for a given object instance. The constructor
property is automatically assigned to all objects when they are created using the constructor for
the Object class.
Example
The following example is a reference to the constructor function for the myObject object.
var my_str:String = new String("sven");
trace(my_str.constructor == String); //output: true
If you use the instanceof operator, you can also determine if an object belongs to a specified
class:
var my_str:String = new String("sven");
trace(my_str instanceof String); //output: true
However, in the following example the Object.constructor property converts primitive data
types (such as the string literal seen here) into wrapper objects. The
instanceof operator does
not perform any conversion, as seen in the following example:
var my_str:String = "sven";
trace(my_str.constructor == String); //output: true
trace(my_str instanceof String); //output: false
See Also
instanceof