A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/statements/this below:

this · WebPlatform Docs

this Summary

Refers to the current object.

Syntax
this.property
Examples

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;
 }

The this keyword generally refers to the window object if used outside of the scope of any other object. However, inside event handlers this refers to the DOM element that raised the event.

In the following code (for Internet Explorer 9 and later), the event handler prints the string version of a button that has an ID of "clicker".

document.getElementById("clicker").addEventListener("click", eventHandler, false);

         function eventHandler(ev) {
             document.write(this.toString());
         }

 
Remarks

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

The this keyword can be used in object constructors to refer to the current object.

See also Other articles Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4