How to implement custom event in JavaScript
<p>I understand how it is possible to create custom events by <code>createEvent, addEventListener</code>. But how can I do something like:</p>

<pre><code>object.dispatchEvent(myevent);

object.myevent=function(){SomeJavaScriptCode};
</code></pre>

<p>Note: This is not duplicate. I'm not asking how to do custom events. I want to know if it is possible to do <code>document.myEvent = function() {}</code> instead <code>document.addEventListener("myEvent",myEventHandler,false);</code> </p>
