<script> var Module = (function () { var my = {}; function privateMethod() { } my.moduleProperty = 1; my.moduleMethod = function () { } return my; } ()); //为防止修改内部的变量 console.log(Module.moduleProperty);//1 Module.moduleMethod = 2; console.log(Module.moduleProperty);//1 </script>