two ways of IIFE(immediately-invoked-function-expression)-JS
来源:互联网 发布:艺恩咨询数据库 编辑:程序博客网 时间:2024/05/21 15:05
one way:
file 2,IIFE-test.html
omit html codes.
file1, IIFE.js
(function() { var jQuery = { myAlert:function myAlert(){ alert("IIFE Test"); } }; window.jQuery = jQuery;})();
file 2,IIFE-test.html
<html> <script type="text/javascript" src="IIFE.js"></script> <script type="text/javascript"> jQuery.myAlert(); </script></html>
js codes,
var jQuery = function(){ var myAlert = function(){ alert("test"); } return{ myAlert : myAlert };}();
omit html codes.
more:
1. http://learn.jquery.com/javascript-101/scope/
2. http://benalman.com/news/2010/11/immediately-invoked-function-expression/
- two ways of IIFE(immediately-invoked-function-expression)-JS
- Immediately-Invoked Function Expression (IIFE)
- js学习小结(十五)2014.7.22-Javascript中的IIFE--(Immediately Invoked function Expression)
- IIFE (Imdiately Invoked Function Expression 立即执行的函数表达式)。
- js executed immediately function
- IIFE (immediate-invoke function expression ) in javascript
- two ways of multiThread
- Two ways of using Iterator
- (function ( ){...})( ) IIFE 的原理
- The two ways of creating Thread
- two ways of saving figure windows
- two arguments of main function
- 说一说JS的IIFE
- 部分译文 - Summary of Ways to Reference the jQuery Function
- Two ways of mental ray proxy work flow
- IOS学习笔记---Two ways of getting data
- Two ways to create a new thread of execution
- javascript 中 正则表达式两种表达方式(regexp in javascript two ways expression)
- Android 打开Url时出现浏览器选择框
- Fibinary Numbers
- 字符串问题:输出第二个字符串在第一个字符串中的连接次序
- Hash冲突的解决--暴雪的Hash算法
- 数据分析学习笔记-NetworkX的使用1
- two ways of IIFE(immediately-invoked-function-expression)-JS
- ------------------用SQL读取某目录下EXCEL文件的内容----------------
- VirtualBox常用命令
- 领导的力量
- iocp的一些有用资料
- struts2批量增加
- jQuery UI Datepicker添加时分秒
- 探秘Java虚拟机 gc的监控
- URAL 1018 (金典树形DP)