更新时间:2023-12-05 23:38:16
IMO替代3是***的。但它假设窗口
表示全局范围 - 对于浏览器而言是这样,但对于其他JS环境(命令行,Node.js等)则不然。
IMO alternative 3 is best. But it assumes that window
represents the global scope - which is true for the browser but not for other JS environments (command line, Node.js, etc.).
以下内容将全面运作:
(function(globals){
"use strict";
globals.GLOB = {};
}(this));