Share via


this 陳述式

更新:2007 年 11 月

參考目前的物件。

 this.property

引數

  • property
    必要項。現有物件的屬性識別項。

備註

物件建構函式通常使用 this 關鍵字來引用目前的物件。

範例

在以下範例中,this 代表剛建立的 Car 物件,並指定三個屬性的值:

function Car(color, make, model){
   this.color = color;
   this.make = make;
   this.model = model;
}

在用戶端版的 JScript 中,若於任何其他的物件內容外使用 this,則代表參考 window 物件。

需求

1 版

請參閱

參考

new 運算子