回调函数 - 使用括号 [英] Callback function - use of parentheses

查看:155
本文介绍了回调函数 - 使用括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jQuery的新手,并且对使用(或不使用)带有回调函数的括号感到困惑。假设我有一个功能:

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 something
}

现在有什么区别:

$("p").hide(1000, cb);

$("p").hide(1000, cb());

执行cb函数时是否与有关?如果有人能用最简单的术语向我解释这一点会很棒。

Is it to do with when the cb function is executed? It would be great if someone could explain this to me in the simplest of terms.

推荐答案

cb( )表示执行函数 cb 的结果。

cb() means give me the result of executing the function cb.

cb 是函数 cb ,或者更准确地说是指针(引用)。

cb IS the function cb or, more accurately a pointer (reference) to it.

这篇关于回调函数 - 使用括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆