表示創(chuàng)建對象的函數(shù)。
object.constructor
必需的 object是對象或函數(shù)的名稱。
constructor 屬性是所有具有 prototype 的對象的成員。它們包括除 Global 和 Math 對象以外的所有 JScript 內(nèi)部對象。constructor 屬性保存了對構(gòu)造特定對象實例的函數(shù)的引用。例如:
x = new String("Hi");
if (x.constructor
== String)
// 進行處理(條件為真)。
或
function MyFunc {
// 函數(shù)體。
}
y = new MyFunc;
if (y.constructor
== MyFunc)
// 進行處理(條件為真)。
應(yīng)用于:Array Object | Boolean 對象 | Date 對象 | Function 對象 | Math 對象 | Number 對象 | Object 對象 | String 對象