Question: Why am I getting this error?

```none
Cannot read property 'target' of undefined
  at btn

```

I declare `btn()` in my html file. I have multiples buttons in the html invoking `btn()`.

```
function btn(event){        
  var theTarget = event.target;
  alert(theTarget.tagName);
}

```

Answer: 
Suggests that the `event` parameter has not been set (i.e. is undefined) when the `btn(...)` method was called.

You should verify that `event` is set whenever the code tries to use that method.

It might also be safer to not use `event` as the parameter name in your function - this might cause problems (i.e. it's [apparently a global variable in IE](https://stackoverflow.com/a/1510106/1751331)). Try changing it to `myEvent`?
Note: When we call the function from the HTML we get the button directly i.e. the `target`. 

With binding we get `event`

```js
function btn(event){        
    var theTarget = event.target || event;
    alert(theTarget.tagName);
}

document.querySelector('#boundEvent').onclick = btn;
```

```html
<!-- In this way we are passing the button directly. -->
<button onclick="btn(this);">Direct call</button>
<!-- When we bind in our code (Best way) we will get an event object. --> 
<button id="boundEvent">Bound Event</button>
```