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`?
By default function takes arguments values as **undefined** in JavaScript so I wish you have forgotten to pass **event** to handler function i.e. to **btn()**.

> 
> A best simple example to understand this concept would be 
>  <https://www.w3schools.com/jsref/event_target.asp>
> 
> 
> 

So instead of calling like `onclick=btn()` or `onclick=btn(this)`, prefer `onclick=btn(event)`, the correct one otherwise `undefined` will be taken as default value.