Javascript回调函数的差异 [英] Javascript callback functions differences
本文介绍了Javascript回调函数的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道2个回调函数实现之间的区别。
I would like to know the difference between 2 implementations of callback functions.
这:
$("#button").on('click', function () {
//do something
});
与已经定义的功能对比。
Versus having the function already defined.
$("#button").on('click', btnFunction);
function btnFunction() {
//do something
}
与另一个相比,是否存在任何影响?性能方面是一个更快?
Are there any implications with one compared to another? Performance-wise is one faster?
推荐答案
第一个使用匿名函数而第二个不使用。两者都没有区别。
The first uses an anonymous function and the second does not. There's no difference in both.
请参阅:
为什么需要在同一行上调用匿名函数?
这篇关于Javascript回调函数的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文