請解釋爲什麼在評論真正的代碼和代碼顯示完全相同的結果
爲什麼下面的代碼 「的document.getElementById(id)的.onclick = [..]」 顯示同樣的結果
<p>Click button to display date</p>
<button type="button" id="button">Click</button>
<p id="paragraph"></p>
<script>
function display() {
var d = new Date();
document.getElementById("paragraph").innerHTML=d;
}
document.getElementById("button").onclick=display;
/* Why does above line shows same results shown by:-
document.getElementById("button").onclick=function() { display(); };
*/
</script>