JS-Bind-callback
HTML
<html>
<body>
<button id="button1">
Click me for undefined
</button>
<button id="button2">
Click me for name
</button>
</body>
</html>
JavaScript
var person = {
firstName: "Jensen",
lastName: "Ackles",
fullName: function () {
console.log(this.firstName + " " + this.lastName);
}
}
document.getElementById("button1").onclick = person.fullName;
document.getElementById("button2").onclick = person.fullName.bind(person);