tags:

views:

99

answers:

4

what is 'this' keyword and what's its functions?

+3  A: 

The this keyword refers to the current object in the context in which the keyword appears.

Here's an article with more: http://www.quirksmode.org/js/this.html

FrustratedWithFormsDesigner
A: 

The this refers as to the object you are currently in. For example, if your object has a method called doSomething(), you could call the method , from another method in your class by doing:

this.doSomething();

Hope this helps.

Live
A: 

this refers to the current object, so its methods are those defined by the class that the current object is an instance of.

Rowland Shaw
+1  A: 

In Java this refers to the object you are currently in. See http://download.oracle.com/javase/tutorial/java/javaOO/thiskey.html

In JavaScript that is true as well, but in a function it can mean the "owner" of a function or the global object (ie window). See http://www.quirksmode.org/js/this.html

Adam