Question: How much I dig into JavaScript, I find myself asking that much. For example we have `window.onresize` event handler and if I say:

```
window.onresize = resize;

function resize()
{
  console.log("resize event detected!");
}

```

Wouldn't that kill all other functions which is connected to the same event and just log my message in console?

If so I think there should be another notifier which tells me about window resize event - or a workaround maybe - without overriding other functions which are bound to same event. 

Or am I totally confused by its usage?

Answer: 
Instead of replacing such a catch-all handler, you should just *add* a [DOM 2 listener](http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget) like this:

```
window.addEventListener("resize", myResizeFunction);

```

or in more details:

```
if (window.addEventListener) {    // most non-IE browsers and IE9
   window.addEventListener("resize", myResizeFunction, false);
} else if (window.attachEvent) {  // Internet Explorer 5 or above
   window.attachEvent("onresize", myResizeFunction);
}

```
One way of doing it is like this:

```
function resize() { /* ... */ }

var existing = window.onresize;
window.onresize = function() {
    if (existing) {
        existing();
    }
    resize();
 }

```

Or you can use something like [jQuery](http://jquery.com/) which wraps all that stuff in a much simpler construct:

```
$(window).resize(function() { /* ... */ });

```

That automatically handles multiple handlers and stuff for you.