立即执行函数模块化
(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);