Calling a function in JavaScript without parentheses

前端 未结 7 1653
醉梦人生
醉梦人生 2020-12-09 07:27

Is there a way in JavaScript to call a function without parentheses?

For example in jQuery:

$(\'#wrap\').text(\"asdf\"); will work and so will <

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 07:49

    You can make a function reference, but you won't be able to pass arguments:

    function funky() { alert("Get down with it"); }
    
    obj.onclick = funky;
    

提交回复
热议问题