Event run before click button
<p>this is my code :</p>

<pre><code>&lt;body&gt;
    &lt;button id="mybtn"&gt;Click Me!&lt;/button&gt;
     &lt;script&gt;
         document.getElementById("mybtn").onclick = sum(2,5);
        function sum(a,b) {
            document.getElementById("x").innerHTML = a + b;
        }
    &lt;/script&gt;
&lt;/body&gt;
</code></pre>

<p>why document show 7 before click button?</p>