收集整理 时间是: 02/06/06 下午 01:17:43.
文件名称: jsstmthis.htm
页面标题: this 语句  •  文件大小: 1778  •  最后更新: Mon, 06 Feb 2006 02:23:50 GMT

this 语句

指当前对象。

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 运算符