多彩编程 多彩编程MZPH · CODE BLOG
ARTICLE DETAIL

文章详情

深耕前端与后端开发技术的一线实战笔记与踩坑复盘。

立即执行函数模块化

立即执行函数模块化 (function(window,$){// 数据letdataI am a module;// 操作数据的函数functionfoo(){console.log(foo()${data});$(body).css(background,red);}functionbar(){console.log(bar()${data});otherFun();//内部调用}// 内部私有函数functionotherFun(){console.log(otherFun());}//暴露APIwindow.$myModule{foo,bar};})(window,jQuery);
返回列表