网络编程 
首页 > 网络编程 > 浏览文章

js自调用匿名函数的三种写法(推荐)

(编辑:jimmy 日期: 2025/6/25 浏览:3 次 )

第一种:

(function(){ 
   console.log(‘hello world”) 
})() 

第二种:

(function(){ 
   console.log(‘hello world') 
}()) 

 第三种:

!function(){ 
   console.log(‘hello world') 
}() 

以上这篇js自调用匿名函数的三种写法(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

上一篇:AngularJS入门教程之REST和定制服务详解
下一篇:AngularJS 入门教程之事件处理器详解