Callback function - use of parentheses

后端 未结 4 1882
滥情空心
滥情空心 2020-12-03 08:21

I\'m new to jQuery and am bit confused about the use (or not) of parentheses with a callback function. Say I have a function:

function cb() {
 // do somethin         


        
4条回答
  •  -上瘾入骨i
    2020-12-03 08:54

    Is it to do with when the cb function is executed?

    Essentially, yes, though the difference does run a little deeper than that.

    • cb is a reference of sorts to the function. You're passing the function along as a parameter to be invoked somewhere down the line.

    • cb() is a function call; the function will be invoked, and the result passed as an argument to .hide.

提交回复
热议问题