Table of Contents

Object.constructor Property Flash 5

a reference to the class constructor function used to create the object read/write
someObject.constructor

Description

The constructor property stores a reference to the constructor function that was used to create someObject. For example, the constructor property of a Date object is the Date constructor function:

now = new Date();
now.constructor =  = Date;       // Yields true

Note that in JavaScript, the constructor property is always read from someObject's constructor's prototype property (someObject._ _proto_ _.constructor). In Flash Player 6 and Flash Player 5, the constructor property is written directly to someObject so that it always faithfully refers to someObject's actual constructor function. For a complete discussion of this subtle deviation, see Section 12.7.3 in Chapter 12.

Usage

Overwriting an object's constructor property is not recommended, because it alters the natural structure of class inheritance.

See Also

Section 12.7.2 and Section 12.7.3


Table of Contents