(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.