何时在回调函数名称后使用()? [英] When to use () after a callback function name?

查看:42
本文介绍了何时在回调函数名称后使用()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
在JavaScript中,如果我用括号调用函数会有所不同?

这有什么区别?

$("a").on("click", anotherFunction);

和这个:

$("a").on("click", anotherFunction());

有没有办法使没有匿名功能的最后一个自我可执行文件?

And is there a way to not make the last one self executable without anonymous function?

推荐答案

第一个传递实际功能;第一个传递实际功能.第二个传递函数的返回值.

The first one passes the actual function; the second passes the returned value of the function.

我不清楚你最后一个问题的含义.

I'm unclear on the meaning of your final question.

这篇关于何时在回调函数名称后使用()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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