] this - is a keyword in the javascript (and other) programming languages
] this - is used as a shortcut reference to refer to the current object,
] this - 'refers' to the object that invokes the call to this ...., ( aka the currently active object )
] First, know that all functions in JavaScript have properties, just as objects have properties.
] And when a function executes, it gets the this property
—a variable with the value of the object that invokes the function where this is used.(SRC = 1)
] this reference ALWAYS refers to (and holds the value of) an object—a singular object—and
] this is usually used inside a function or a method,
] this can be used outside of a function in the global scope.
] this has some 'gotchas' which can make it a 'bit tricky/trickier/? to work with' in some cases
] this - inside a closure,
] this - global scope
] this - strict mode - Note that when we use strict mode, this holds the value of undefined in global functions and in anonymous functions that are not bound to any object.
] this is used to refer to || reference the 'currently active' object
] shorthand,
[] see example 1
] the POWER of
[] this lies WHERE you dont know the reference to something, ie a web page has 20 links, i dont know which link the user will click, BUT i can write 1 'link click' function and THEN using the 'this' function i could get the value of the link that you the user clicked, var youClicked = this.id; and avoid the pain of having to write an individual link click function for each link on the page
[WHERE]
] * this is assigned a value when an object invokes the function where this is defined
[WHEN]
]
]
[EXAMPLE]
] to get a reference to the current pages title, i could use
] var t = document.title; OR because the window object has the current
] var t = this.title;
[HOW-TO]
] the important part is knowing what .this is referring to at the time you are referencing it