Calling a function in JavaScript without parentheses

前端 未结 7 1645
醉梦人生
醉梦人生 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条回答
  •  春和景丽
    2020-12-09 07:42

    Use template literals:

    alert`WOW`
    

    It is cleaner and shorter, without having to rely on jQuery, call, etc.

提交回复
热议问题