What is the difference between btn.onclick=st; and btn.onclick=st ();?

<!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
<input type="button" value="anniu" id="btn" name="">
  <script type="text/javascript">
    var btn=document.getElementById("btn");
      function st(){
      alert("sd")
    }
    btn.onclick=st;
  </script>
</body>
</html>
When

is written as btn.onclick=st (); , the page opens and alert pops up directly. Why? How does this work?

May.22,2021

btn.onclick=st();

is equivalent to executing st () and assigning st () to btn.onclick


btn.onclick=st() 
document.getElementById('btn').onclick = function(){
 alert("sd")
}
Menu