This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.

Smartphone icons created by Freepik - Flaticon

JavaScript "this"

This example demonstrate that in Arrow Functions, the "this" keyword represents the object that owns the function, no matter who calls the function.

Click the button to execute the "hello" function again, and you will see that "this" still represents the window object.

let hello = "";

hello = () => {
  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);