1 (function(){ 2 var moduleName = function(){ 3 //dosomething 4 }; 5 if (typeof module !== 'undefined' && typeof module.exports === 'object') { 6 module.exports = moduleName; 7 } else if (typeof define === 'function' && (define.amd || define.cmd)) { 8 define(function() { return moduleName; }); 9 } else { 10 this.moduleName = moduleName; 11 } 12 }).call( this || (typeof window !== 'undefined' ? window : global));//this可能为null