// js中通过作用域来实现私有和公共函数 var myObject = (function () { var __name = 'xin'; // 私有 return { getName: function () { return __name; // 公开 } } })();