Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

this Statement (JavaScript)

Refers to the current object.

this.property

The required property argument is one of the current object's properties

The this keyword is typically used in object constructors to refer to the current object.

In the following example, this refers to the newly created Car object, and assigns values to three properties:

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

For client versions of JavaScript, this refers to the window object if used outside of the context of any other object.

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Show:
© 2015 Microsoft