I have a basic javascript class with two properties. I want to log the value of one on a click event. Here is what I got:
function Clicker(/*string*/var1, /*id*/var2) {
    this.name = var1;
    this.clickerid = var2;
    this.clickevent = function() {
        console.log("1: " + this.name);
        console.log("2: " + this);
        console.log("3: " + window.testClicker.name);
    };
    var element = document.getElementById(this.clickerid);
    element.addEventListener("click", this.clickevent, false);
}
window.onload = function() {
    window.testClicker = new Clicker("lorem ipsum", "checkbox1");
};
<input id="checkbox1" type="checkbox" value="1" checked>
When I run my test I see the following in the log:
1: undefined
2: <input id="checkbox1" type="checkbox" value="1" checked>
3: lorem ipsum
I was expecting to see the first and third lines match. Suggestions?