JS自执行函数的几种写法

  一:总体写在一个括号中javascript

       代码以下:java

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

二:function函数总体外加括号函数

     代码以下:spa

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

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

!function Show(){alert("hello");}()
或者
void function Show(){alert("hello");}()
相关文章
相关标签/搜索