立即执行函数模块化
📅 2026/8/2 19:06:42
👁️ 阅读次数
📝 编程学习
(function(window,$){// 数据letdata='I 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);
编程学习
技术分享
实战经验