With below code I noticed that in the browser console when I log the event, the value for currentTarget logs null. However when I log e.currentTarget it logs a value. Any idea's on how that works?
var button = document.getElementById("btn");
var eventButtonHandler = function(e) {
var button = e.target;
console.log(e); // logs MouseEvent object with currentTarget:null
console.log(e.currentTarget); // logs a value
if(!button.classList.contains("active"))
button.classList.add("active");
else
button.classList.remove("active");
};
button.addEventListener("click", eventButtonHandler);
A jsbin can be found here: http://jsbin.com/xatixa/2/watch?html,js,output