JS自执行函数的几种写法

  一:整体写在一个括号中

       代码如下:

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

二:function函数整体外加括号

     代码如下:

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

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

!function Show(){alert("hello");}()
或者
void function Show(){alert("hello");}()
原文地址:https://www.cnblogs.com/net-study/p/4917197.html