(function(){})()和(function(){}())之间的区别,自调用匿名函数 [英] Different between (function(){})() and (function(){}()) , self invoking anonymous function
本文介绍了(function(){})()和(function(){}())之间的区别,自调用匿名函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
看看括号的位置,是否有任何不同?
Look at the placement of the parenthesis, is that any different?
(func)()
(function(){
})();
和(func())
(function(){
}());
推荐答案
从技术上讲,第一个定义一个匿名函数,然后调用它,第二个定义了一个匿名函数,它根据自己的定义调用自己。实际上,它们完全相同。
Technically the first defines an anonymous function, then calls it, the second defines an anonymous function which calls itself as it's defined. Realistically, they are identical.
这篇关于(function(){})()和(function(){}())之间的区别,自调用匿名函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文