crop_rotate
Run
<!DOCTYPE html> <html> <body> <h2>JavaScript "this"</h2> <p>This example demonstrate that in a regular function, the "this" keyword represents different objects depending on how the function was called.</p> <p>Click the button to execute the "hello" function again, and you will see that this time "this" represents the button object.</p> <button id="btn">Click Me!</button> <p id="demo"></p> <script> var hello; hello = function() { document.getElementById("demo").innerHTML += this; } //The window object calls the function: window.addEventListener("load", hello); //A button object calls the function: document.getElementById("btn").addEventListener("click", hello); </script> </body> </html>
PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCjxib2R5Pg0KDQo8aDI+SmF2YVNjcmlwdCAidGhpcyI8L2gyPg0KDQo8cD5UaGlzIGV4YW1wbGUgZGVtb25zdHJhdGUgdGhhdCBpbiBhIHJlZ3VsYXIgZnVuY3Rpb24sIHRoZSAidGhpcyIga2V5d29yZCByZXByZXNlbnRzIGRpZmZlcmVudCBvYmplY3RzIGRlcGVuZGluZyBvbiBob3cgdGhlIGZ1bmN0aW9uIHdhcyBjYWxsZWQuPC9wPg0KDQo8cD5DbGljayB0aGUgYnV0dG9uIHRvIGV4ZWN1dGUgdGhlICJoZWxsbyIgZnVuY3Rpb24gYWdhaW4sIGFuZCB5b3Ugd2lsbCBzZWUgdGhhdCB0aGlzIHRpbWUgInRoaXMiIHJlcHJlc2VudHMgdGhlIGJ1dHRvbiBvYmplY3QuPC9wPg0KDQo8YnV0dG9uIGlkPSJidG4iPkNsaWNrIE1lITwvYnV0dG9uPg0KDQo8cCBpZD0iZGVtbyI+PC9wPg0KDQo8c2NyaXB0Pg0KdmFyIGhlbGxvOw0KDQpoZWxsbyA9IGZ1bmN0aW9uKCkgew0KICBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiZGVtbyIpLmlubmVySFRNTCArPSB0aGlzOw0KfQ0KDQovL1RoZSB3aW5kb3cgb2JqZWN0IGNhbGxzIHRoZSBmdW5jdGlvbjoNCndpbmRvdy5hZGRFdmVudExpc3RlbmVyKCJsb2FkIiwgaGVsbG8pOw0KDQovL0EgYnV0dG9uIG9iamVjdCBjYWxscyB0aGUgZnVuY3Rpb246DQpkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiYnRuIikuYWRkRXZlbnRMaXN0ZW5lcigiY2xpY2siLCBoZWxsbyk7DQo8L3NjcmlwdD4NCg0KPC9ib2R5Pg0KPC9odG1sPg==