网站制作学习网JS脚本→正文:this语句
字体:

this语句

JS脚本 2009/9/20 10:18:33  点击:不统计

this 语句指当前对象。
this.property
必选的 property 参数指的是对象的属性。
说明
this 关键字通常在对象的 构造函数中使用,用来引用对象。
示例
在下面示例中,this 指的是新创建的 Car 对象,并给三个属性赋值。

function Car(color, make, model){
  this.color = color;
  this.make = make;
  this.model = model;
}
对于 JScript 的客户版本,如果在其他所有对象的上下文之外使用 this,则它指的是 window 对象。

·上一篇:switch语句 >>    ·下一篇:switch语句 >>
推荐文章
最新文章