function(){alert('sss')}
是个匿名函数。没有名字。所以没有办法调用。
在外面加个括号,就变成了一个值,值的内容是函数的引用。例如
var a = (function(){"nop"})
a 就是对这个函数的引用。有了名字,之后可以调用,例如a()

现在省略了a,直接对()中的值进行调用就出现了()()的形式,第一个括号中是个函数,就是这样。

如果还不懂,看看下面三段代码试试:

 

<script>

(function(){

  function a(){

    function b(){}

  }

  alert(typeof a); // a 可见

  alert(typeof b); // b 不可见

})()

</script>

 

 

<script>

(function(){

  function a(){

    function b(){}

alert(typeof b);

  }

  a(); // b 可见

  alert(typeof a); // a 可见

  alert(typeof b); // b 不可见

})()

</script>

 

 

<script>

(function(){

  (function a(){

    function b(){}

alert(typeof b); // b 可见

  })()

  alert(typeof a); // a 不可见

  alert(typeof b); // b 不可见

})()

</script>