JS自执行函数的几种写法

  一:整体写在一个括号中

       代码如下:

(function Show(){alert("hello");}())

二:function函数整体外加括号

     代码如下:

(function Show(){alert("hello");})()

 三:function前加一元运算符或者“void”

!function Show(){alert("hello");}()
或者
void function Show(){alert("hello");}()

 

posted on 2015-10-28 14:19  MisterS  阅读(1298)  评论(0编辑  收藏  举报

导航