This Keyword

Inside the class body this refers to the current class object.

It can be used to access / modify properties and call functions inside the class.

Example

Output:

Explanation:

  • At lines 22, 23 values are set to the properties width and height.
  • At line 25 the printData function is called. this points to the class object.