1.
(
    function (){
        alert(1)
    }
)()2.
(
    function (){
        alert(2)
    }()
)为什么ext源代码用的是第一种? 

解决方案 »

  1.   

    运行完会报错的...不信你在最后加一个alert(3) 看会不会执行到那...
      

  2.   

    <html>
    <head>
    <style></style>
    </head>
    <body></body>
    </html>
    <script>(
    function (){
    alert(1)
    }
    )()(
    function (){
    alert(2)
    }()
    )alert(3);
    </script>
      

  3.   

    ie6 不会错 ff会。 我再去研究研究匿名函数的调用 谢谢阿。
      

  4.   


    (
    function (){
    alert(2)
    }()
    )
    ;alert(3)
    第一种写法好看~
      

  5.   

    搜了N多帖子之后终于找到了个比较权威的解释:http://blog.silentash.com/2009/06/the-javascript-anonymous-function/