July 1998
Intermediate to advanced
1456 pages
65h 5m
English
this — NN 2 IE J1 ECMA 1
A keyword that refers to the current object. For example, in a form element object event handler, you can pass the object as a parameter to the function:
<INPUT TYPE="text" NAME="ZIP" onChange="validate(this)">
Inside a custom object constructor, the keyword refers to the object itself, allowing you to assign values to its properties (even creating the properties at the same time):
function CD(label, num, artist) {
this.label = label
this.num = num
this.artist = artist
}Inside a function, the this keyword refers to the
function object.
<INPUT TYPE="text" NAME="phone" onChange="validate(this.value)">
Read now
Unlock full access